A
A
Asen1232022-01-18 19:05:38
PHP
Asen123, 2022-01-18 19:05:38

How to get og:image value from social networks?

Hello. There was a problem, unable to get the value of the og:image meta tag. The bottom line is that I want to get a photo of a social network user when entering a link to his page. How can this be implemented? I tried parsing, but some social networks do not have this value (such as twitter), and some do not give access to this value (for example, 'vk' gives a 403 error). How can the problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2022-01-18
@SilenceOfWinter

https://www.php.net/manual/en/function.get-meta-ta...

$tags = get_meta_tags('http://site.com/') + ['og:image' => ''];
echo $tags['og:image'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question