谷歌加上粉丝的追随者

时间:2012-01-10 22:20:41

标签: json google-plus

如何以纯文本格式获取Google加关注者? JSON或XML https://developers.google.com/+/api/latest/people/get没有关注者字段密钥。

6 个答案:

答案 0 :(得分:4)

目前无法通过API从Google+获取关注者(或任何圈子信息)。

答案 1 :(得分:3)

您可以使用API​​密钥,但必须确保Google加上关注者的可见性应该是公开的

尝试小提琴:https://jsfiddle.net/himstar/j4932w0s/

var profileid = '100520061367519307358';
var apikey = 'AIzaSyAqlZ1MJSGXMSs8q5WbfvLpZTGJeHLVc2w';
var url = 'https://www.googleapis.com/plus/v1/people/' + profileid + '?key=' + apikey;
$.ajax({
    type: "GET",
    dataType: "json",
    url: url,
    success: function (data) {
        var googlefollowcount = data.circledByCount;
        $(".googlefollowercount").html(googlefollowcount);
    }
});

答案 2 :(得分:2)

实际上有:http://www.emoticode.net/ruby/get-google-page-followers-count-with-google-api.html

require 'open-uri'
require 'json'

google_api_key = 'put your google api key here'
page_id = '105672627985088123672'

data = open("https://www.googleapis.com/plus/v1/people/#{page_id}?key=#{google_api_key}").read    
obj = JSON.parse(data)

puts obj['plusOneCount'].to_i

使用Ruby。

答案 3 :(得分:2)

在php中:

// get api https://code.google.com/apis/console?hl=en#access
$google_api_key = 'YOUR_API';
$page_id = 'YOUR_PAGE_ID';
$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'];

答案 4 :(得分:0)

您可以使用People.list方法检索所有圈子,例如:

...
Plus.People.List listPeople = plus.people().list("me", "visible");
listPeople.setMaxResults(5L);

PeopleFeed peopleFeed = listPeople.execute();
List<Person> people = peopleFeed.getItems();
...

Try the example in the APIs Explorer

答案 5 :(得分:0)

截至2018年8月,Google + API端点https://www.googleapis.com/plus/v1/people/userId/people/collection is deprecated

There is a new endpoint用于获取所有联系人:https://people.googleapis.com/v1/people/me/connections。 响应中有一个metadata键,对于Google+联系人,它看起来会像这样:

  "metadata": {
    "sources": [
      {
        "updateTime": "2013-01-13T19:16:50.668Z", 
        "etag": "...", 
        "type": "CONTACT", 
        "id": "..."
      }, 
      {
        "etag": "...", 
        "type": "PROFILE", 
        "id": "...", 
        "profileMetadata": {
          "userTypes": [
            "GOOGLE_USER", 
            "GPLUS_USER"
          ], 
          "objectType": "PERSON"
        }
      }
    ], 
    "objectType": "PERSON"
  }

请注意"GPLUS_USER"部分。