How to Fetch Google Plus circles in IOS Sdk

微笑、不失礼 提交于 2020-01-07 03:42:05

问题


I am using Google Plus integration where I have to fetch circles of user.

I am passing the Url:https://www.googleapis.com/plus/v1/people/Your_User_Id/people/visible?key=APP_Key.

I am getting the response as:

{ error = { code = 403; errors = ( { domain = global; message = Forbidden; reason = forbidden; } ); message = Forbidden; }; }

What kind of permission do I need for This request?


回答1:


You can only do this for the signed in user - so the "Your_User_Id" should always be "me". It's fine to pass the app key as well, but you must be making the call with an oAuth 2.0 token from a user who has signed in to your app. You can see all the details here: https://developers.google.com/+/mobile/ios/people#retrieve_a_collection_of_people

Basically you'd need to implement sign-in, if you haven't already, then you can use the plusService in the GPPSignIn sharedInstance:

GTLQueryPlus *query =
    [GTLQueryPlus queryForPeopleListWithUserId:@"me"
                                    collection:kGTLPlusCollectionVisible];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket,
                            GTLPlusPeopleFeed *peopleFeed,
                            NSError *error) {
            if (error) {
              GTMLoggerError(@"Error: %@", error);
            } else {
              // Get an array of people from GTLPlusPeopleFeed
              NSArray* peopleList = [peopleFeed.items retain];
            }
        }];

That is calling the URL that you're giving there.



来源:https://stackoverflow.com/questions/17562691/how-to-fetch-google-plus-circles-in-ios-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!