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 ?
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.
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.
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/ )
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.
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>';
}
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