Now a lot of scripts to facebook-style fetching data from url, but all of them work only in combination of jQuery and PHP. Is it possible to fetch url only by jQuery?
I have found here how to get mata-tags of page by:
$('meta[name=description]').attr("content");
$("meta[property=og:title]").attr("content", document.title);
But how correctly insert this query in jQuery.get() to get text values?
$.get('http://www.imdb.com/title/tt1375666/', function(data) {
$('meta[name=adescription]').attr("content");
});
And if the most popular sites use OpenGraph should I look in the direction of jQuery.getJSON()?
It seems like this wouldn't be possible because of the Cross Origin Policy
There are definitely ways of doing it with combination client & server side changes. Instead I've been using this API in a project that works well as a simple REST API to get a url's open graph data.
GET https://opengraph.io/api/1.0/site/<URL encoded site URL>
https://opengraph.io/
It's been working for me as a client-side javascript only solution.
[NOTE: I have no relationship to this product or its creators. I found it through online research and used it in a project.]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With