使用php(curl)阅读g + fanpage上的帖子

时间:2014-03-19 16:35:10

标签: php rest curl google-api google-plus

我正在尝试使用php阅读g + fanpage的最新帖子。唉,文档对如何做到这一点没有帮助:/

到目前为止,我已经尝试了以下内容:

<?php
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, 'https://www.googleapis.com/plus/v1/people/{userID}/activities/public?key={apikey}');
curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
$jsonData = json_decode(curl_exec($curlSession));
curl_close($curlSession);
当然,

{apikey}{userID}是占位符。我通过Developers Console生成了api密钥,服务器密钥和浏览器密钥都没有对下面的结果产生任何影响。 Google+ API已激活。

结果如下:

{
   "error":{
      "errors":[
         {
            "domain":"usageLimits",
            "reason":"accessNotConfigured",
            "message":"Access Not Configured. Please use Google Developers Console to activate the API for your project."
         }
      ],
      "code":403,
      "message":"Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
}

你对出了什么问题有什么建议吗?我错过了什么吗? 我是否必须提供此类API请求的帐单信息?

1 个答案:

答案 0 :(得分:2)

它在错误消息中告诉您错误... Please use Google Developers Console to activate the API for your project.

转到此处https://code.google.com/apis/console/,点击左侧点击API&amp; Auth,然后启用Google+ API以及您需要的其他API