Get list of circles of a user using Google Plus API

I am using google aouth with following in scope

scope : ['https://www.googleapis.com/auth/tasks', 'https://www.googleapis.com/auth/tasks.readonly', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.circles.read']

I tried to get information about user, I've used following API

var xhr = Ti.Network.createHTTPClient({
            onload : function() {
                var data = this.responseText;
                var json = JSON.parse(data);
                Ti.API.log('json: ' + JSON.stringify(json));
            }
        });
        xhr.open("GET", "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + googleAuth.getAccessToken());
        xhr.send();

but it only gives information about users basic info, how can I get information about users friends in circle.

I replaced xhr.open("GET", "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + googleAuth.getAccessToken()); with

xhr.open("GET", "https://www.googleapis.com/plusDomains/v1/people/me/circles?access_token=" + googleAuth.getAccessToken());

the responce text in console was like

json: {"error":{"errors":[{"domain":"global","reason":"forbidden","message":"Forbidden"}],"code":403,"message":"Forbidden"}}

I have enabled

  • Google+ API,
  • Blogger API,
  • Google+ Pages API,
  • Google+ Domains API,

Answers:

Answer

The closest thing to this that the API has is People.list

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

Try testing the collection see which one suits your needs more. You can test the results at the bottom of the page. There is no way to get the name of the circle back.

Acceptable values are:

"connected": The list of visible people in the authenticated user's circles who also use the requesting app. This list is limited to users who made their app activities visible to the authenticated user.

"visible": The list of people who this user has added to one or more circles, limited to the circles visible to the requesting application.

Answer

As of August 2018 the Google+ API endpoint https://www.googleapis.com/plus/v1/people/userId/people/collection is deprecated.

There is a new endpoint for getting all the contacts: https://people.googleapis.com/v1/people/me/connections. There is a metadata key in the response, and for Google+ contacts it will look somewhat like this:

  "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"
  }

Note the "GPLUS_USER" part.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.