Google Plus API 计数调用失败


Google Plus API Count Call Failing

>我创建了一个 POST 请求来从 Google Plus 中提取特定 URL 的共享计数,但无法返回任何计数值。

我是否要走很长的路,或者是否有更简单的方法来检索这些数据,例如 Facebook 和 Twitter 提供了一个 URL,您将 URL 传递给您想要检索共享计数的 URL,它以 JSON 格式返回结果!?

GOOGLE_API_KEY id 我从 Google 的开发人员控制台获得的密钥的定义变量Google+ API.

$vRequest = '[{"method":"pos.plusones.get",
    "id":"p",
    "params":{
        "nolog":true,
        "id":"http://www.google.com",
        "source":"widget",
        "userId":"@viewer",
        "groupId":"@self"
    },
    "jsonrpc":"2.0",
    "key":"p",
    "apiVersion":"v1"}]';
$vUrl = "https://clients6.google.com/rpc?key=".GOOGLE_API_KEY;
$vOptions = array(
    'http' => array(
        'header'  => "Content-type: application/json'r'n",
        'method'  => 'POST',
        'content' => $vRequest,
    ),
);
$vContext  = stream_context_create($vOptions);
$vResponse = json_decode(@file_get_contents($vUrl, false, $vContext));

我得到的 JSON 响应是:

array(1) { 
    [0]=> object(stdClass)#1 (2) { 
        ["error"]=> object(stdClass)#2 (3) { 
            ["code"]=> int(403) 
            ["message"]=> string(143) "Access Not Configured. The API (+1 API) is not enabled for your project. Please use the Google Developers Console to update your configuration." 
            ["data"]=> array(1) { 
                [0]=> object(stdClass)#3 (4) { 
                    ["domain"]=> string(11) "usageLimits" 
                    ["reason"]=> string(19) "accessNotConfigured" 
                    ["message"]=> string(143) "Access Not Configured. The API (+1 API) is not enabled for your project. Please use the Google Developers Console to update your configuration." 
                    ["extendedHelp"]=> string(37) "https://console.developers.google.com" 
                } 
            } 
        } 
        ["id"]=> string(1) "p" 
    } 
} 

现在我已经检查了Google的API控制台,Google+ APIGoogle+ Domains API都已启用,不确定我还缺少什么。

这是一个私有API,谷歌尚未向公众提供。您的应用程序未被列入白名单以使用它。有一个开放的功能请求,用于获取 URL 的 +1 计数。

事实证明,

我上面使用的代码不再起作用,Google 在 2013 年进行了更改以阻止使用它,我现在用来获取大致份额计数的代码如下。

$vHtml =  @file_get_contents( "https://plusone.google.com/_/+1/fastbutton?url=".urlencode("http://www.google.com"));
$vDoc = new DOMDocument();
@$vDoc->loadHTML($vHtml);
$vCounter = $vDoc->getElementById('aggregateCount');
echo $vCounter->nodeValue;

在发布此内容时,无法从Google Plus获取共享计数,因为Google尚未通过任何API提供该共享计数。