【发布时间】:2016-09-08 19:25:31
【问题描述】:
我试图在 foreach 中获取 wordpress 帖子 Facebook 分享计数,但是..
<?php
$post_url = the_permalink();
$url_changed = urlencode($post_url);
$json = file_get_contents( 'http://graph.facebook.com/?id=' . $url_changed );
ini_set("allow_url_fopen", 1);
$array = json_decode($json, true);
echo $array['share']['share_count'];
?>
这只会给我 id="" 和错误
file_get_contents(http://graph.facebook.com/?id=):打开失败 流:HTTP 请求失败! HTTP/1.1 400 错误请求
但是如果使用
$json = file_get_contents( 'http://graph.facebook.com/?id=http://www.google.com' );
这样,就可以了。有人知道解决方法或如何解决吗?
【问题讨论】:
标签: php wordpress facebook facebook-graph-api