【问题标题】:How to get facebook share count from New Graph API v2.7如何从 New Graph API v2.7 获取 facebook 分享数
【发布时间】:2016-08-25 10:37:19
【问题描述】:

Facebook REST API 现已弃用。 脸书*:https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json

那么我怎样才能获得我网站的 Facebook 分享数。

新图谱 API v2.7

【问题讨论】:

    标签: php facebook curl


    【解决方案1】:

    请使用下面的代码。 为您的网站创建应用程序 ID 并调用共享页面 URL,它将返回共享计数。 您可以使用 curl 库从 Facebook 检索数据

    $json_string = file_get_contents_curl("https://graph.facebook.com/v2.7/?id=http://example.com/xyz/&access_token=123456789002599|abcdSXS_PJNQ5iEBH098_ABC");

    $json = json_decode($json_string, true);

    echo $json['share']['share_count']

    卷码private function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 300); $cont = curl_exec($ch); if (curl_error($ch)) { return false; } return $cont; }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多