Reputation:
I'm wondering how facebook extracts the open graph values from a link.
<meta property="og:type" content="website">
<meta property="og:url" content="http://sample.com">
<meta property="og:title" content="sample title">
<meta property="og:description" content="sample description">
Cross-domain is a big issue here I think if the link is just on my domain I can do it with AJAX. I also have this idea via <iframe>
like this:
$('iframe').contents().find('meta[property=og:title]').attr("content");
//will output me: 'sample title'
But I've also need to put in consideration the loading/rendering time of an iframe so it's not the best option. Any help would be appreciated, thanks.
PS. Can also someone tell me the supported og:type on facebook, it seems this link is broken: https://developers.facebook.com/docs/reference/opengraph/object-type ; website, blog, article ...?
Upvotes: 2
Views: 1074
Reputation: 13966
AS you correctly pointed out: Cross domain is the big issue here. So this is not request via ajax but it request via a proxy in your site. For example you write an page with php: og.php. THis page will recieve url for input parameter and then craw the url and return og in json format. Only then your javascript can get this json and return to user.
Iframe is also have crossdomain issue so you cannot use iframe
Upvotes: 1