试试这个
$tags = get_meta_tags(\'http://www.bbc.com/news/technology-34527439\');
$title = $tags[\'twitter:title\'];
$content = $tags[\'description\'];
$image = $tags[\'twitter:image:src\'];
如果您可以使用twitter:title和twitter:image:src。您还必须检查您试图从中提取的每个源,以查看它们是否具有一致的元模式。如果bbc改变了。com站点只需在要从中提取标记的站点的某个标识符上执行switch语句即可构建数据数组。
提供URL的输出。
Array
(
[description] => The UK\'s National Crime Agency says cyber-attackers have stolen more than £20m from British bank accounts.
[x-country] => us
[x-audience] => US
[cps_audience] => US
[cps_changequeueid] => 259204896
[twitter:card] => summary_large_image
[twitter:site] => @BBCWorld
[twitter:title] => Online attackers steal £20m from UK bank accounts - BBC News
[twitter:description] => The UK\'s National Crime Agency says cyber-attackers have stolen more than £20m from British bank accounts.
[twitter:creator] => @BBCWorld
[twitter:image:src] => http://ichef.bbci.co.uk/news/560/cpsprodpb/37A1/production/_86114241_thinkstock.jpg
[twitter:domain] => www.bbc.com
[apple-mobile-web-app-title] => BBC News
[application-name] => BBC News
[msapplication-tileimage] => http://static.bbci.co.uk/news/1.91.0426/windows-eight-icon-144x144.png
[msapplication-tilecolor] => #bb1919
[mobile-web-app-capable] => yes
[robots] => NOODP,NOYDIR
[theme-color] => #bb1919
[viewport] => width=device-width, initial-scale=1, user-scalable=1
)
仅供参考-wordpress有一个卷曲包装器,非常有用
wp_remote_get( $url, $args );
https://codex.wordpress.org/Function_Reference/wp_remote_get