Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the best way to get og:image meta property [duplicate]

I am trying to show rss feed links in my website, All going well but its taking so much time to get og:image property by using file_get_contents() method. Is there any other way to fetch meta tag properties?

Is Python helpful to get these tags faster ?

like image 318
vamshichalla Avatar asked Feb 25 '14 11:02

vamshichalla


People also ask

How do you fix the OG image property should be explicitly provided?

Inferred Property The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags. If you do not have the Open Graph tags specified, then Facebook will only fill in the gaps for the image, title, and description.

How do I make an image OG?

You can set a custom og:image on a page by page basis. Just go to Page Settings > Social Image > Upload. If you need to add other OG tags and customize the default settings, go to Page Settings > Advanced > Page Header Code Injection. Read the following section on adding the tags manually and copy-paste the code there.

What is meta property OG?

og:title is one of the open graph meta tags. og:... properties define objects in a social graph. They are used for example by Facebook. og:title stands for the title of your object as it should appear within the graph (see here for more http://ogp.me/ )

What is the OG image property?

An open graph image or OG image is the image that appears when you post a link to a web page or video content on your social media page. This forms part of an important group of meta tags that directly impact how the content links perform on social media platforms, like Facebook, LinkedIn and Twitter.


1 Answers

This is how I used to get all the og:tags:

libxml_use_internal_errors(true);
$doc = new DomDocument();
$doc->loadHTML(file_get_contents($url));
$xpath = new DOMXPath($doc);
$query = '//*/meta[starts-with(@property, \'og:\')]';
$metas = $xpath->query($query);
foreach ($metas as $meta) {
    $property = $meta->getAttribute('property');
    $content = $meta->getAttribute('content');
    echo '<h1>Meta '.$property.' <span>'.$content.'</span></h1>';
}
like image 128
Toni Michel Caubet Avatar answered Nov 16 '22 02:11

Toni Michel Caubet