Google Plus People联系人列表返回0

时间:2017-11-29 14:04:52

标签: c# google-plus google-api-dotnet-client

我想要获取用户Google +帐号的所有圈子中的人员列表。 我使用的是Google People API,但列表始终返回0。 代码如下:

string[] scopes = new string[] {PlusService.Scope.PlusLogin,
            PlusService.Scope.UserinfoEmail,
            PlusService.Scope.UserinfoProfile};
string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            credPath = Path.Combine(credPath, ".credentials/", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
 UserCredential credential =
                    GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
                    {
                        ClientId = "someid",
                        ClientSecret = "somekey"
                    },
                                                                scopes,
                                                                Environment.UserName,
                                                                CancellationToken.None,
                                                            new FileDataStore(credPath,true)
                                                                ).Result;


            PlusService service = new PlusService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Google Plus Sample",
            });

            PeopleResource.ListRequest listPeople = service.People.List("me", PeopleResource.ListRequest.CollectionEnum.Visible);
            listPeople.MaxResults = 10;
            PeopleFeed peopleFeed =  listPeople.Execute();

1 个答案:

答案 0 :(得分:1)

如果您查看people.list的文档,则可以看到此方法不再有效。

  

不推荐使用Google+ People API列表终结点。请考虑使用Google People API。

您可以尝试切换到google people api,但这不是Google+ IIR上的用户列表,而是用户在Google通讯录中设置的用户列表。