如何获得谷歌加页面粉丝的数量?

时间:2015-03-12 15:25:13

标签: google-plus

实际上有可能获得我的googleplus页面的关注者数量。以下脚本 - 我在之前的帖子中找到的 - 不起作用(没有输出):

$google_api_key = 'XYZXYZXYZXYZXYZXYZ';
$page_id = 'MYNUMERICPAGEID';
$data = @file_get_contents("https://www.googleapis.com/plus/v1/people/$page_id?key=$google_api_key");
$data = json_decode($data, true);
echo $data['plusOneCount'];
谢谢你!

1 个答案:

答案 0 :(得分:2)

可能有一些问题:

  • Developer Console上没有更新的项目。
  • 未启用该项目的API。
  • 是过去的门槛/配额。

尝试以下方法:

  1. 登录您的Google Developers Console
  2. 你需要一个项目。
    • 如果您没有项目,请创建一个。
  3. 在该项目上启用“Google Plus API”。
  4. 确认使用/报价在容差范围内,您还没有过去。
  5. 从那里,你的电话应该正常工作:

    GET https://www.googleapis.com/plus/v1/people/{USER_ID}?key={YOUR_API_KEY}
    

    就我而言,我正在查询Google's页面,所以{USER_ID} = 116899029375914044550。然后我可以看到plusOneCount

    {
     "kind": "plus#person",
     "etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/bTf-sq_Sg3fLAFijixPfjtKM5f8\"",
     "urls": [
      {
       "value": "http://www.google.com",
       "type": "website",
       "label": "www.google.com"
      },
      {
       "value": "http://www.google.com/support/",
       "type": "other",
       "label": "Google Help"
      },
      {
       "value": "http://googleblog.blogspot.com/",
       "type": "other",
       "label": "Official Blog"
      },
      {
       "value": "http://twitter.com/#!/google",
       "type": "other",
       "label": "@google"
      },
      {
       "value": "http://www.google.com/about/corporate/company/",
       "type": "other",
       "label": "Company Info"
      },
      {
       "value": "http://www.google.com/press/",
       "type": "other",
       "label": "News"
      },
      {
       "value": "http://www.google.com/press/google-directory.html",
       "type": "other",
       "label": "More Google pages"
      }
     ],
     "objectType": "page",
     "id": "116899029375914044550",
     "displayName": "Google",
     "tagline": "News and updates on Google's products, technology and more",
     "aboutMe": "<p>Welcome to Google&#39;s official page. Here, you&#39;ll find product news and announcements, company updates, glimpses into what it&#39;s like to work at Google, discussions on technology and the web, and much more. </p><p><span>Given the volume of feedback we receive here, we may not be able to respond individually to every comment and we&#39;re not able to provide product support (if you&#39;re having product issues, please visit our Help Center). Rest assured we&#39;re paying attention, and we&#39;re always eager to hear from you.</span></p>",
     "url": "https://plus.google.com/+google",
     "image": {
      "url": "https://lh4.googleusercontent.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAAC9wQ/JD8tdz3bFTM/photo.jpg?sz=50",
      "isDefault": false
     },
     "isPlusUser": true,
     "plusOneCount": 10757884,
     "circledByCount": 7692912,
     "verified": true,
     "cover": {
      "layout": "banner",
      "coverPhoto": {
       "url": "https://lh4.googleusercontent.com/-PLPoXvnN0XI/UTdr4xTtuHI/AAAAAAAA_1U/p1n_Za3BZUg/s630-fcrop64=1,00000000fe06fe97/g_plus_background.png",
       "height": 528,
       "width": 940
      },
      "coverInfo": {
       "topImageOffset": 0,
       "leftImageOffset": 0
      }
     }
    }