【问题标题】:List of Google Plus People contacts returns 0Google Plus People 联系人列表返回 0
【发布时间】:2017-11-29 14:04:52
【问题描述】:

我想获取用户 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();

【问题讨论】:

  • 欢迎来到StackOverflow[SO],请更具体一点when asking question:到目前为止,您对代码示例进行了哪些尝试? / 你能指望什么? / 你得到什么错误?
  • 我期待经过身份验证的用户的人员列表。该id在google plus账号中有各个圈子的人。我也没有收到任何错误。它所做的只是返回一个计数为 0 的列表
  • 然后写在你的问题里,你越具体,用户越能帮助你!我帮不了你,但我可以给你一些提示来提高你的问题质量:)如果你还没有读过它(stackoverflow.com/help/how-to-ask),那么你就知道了。
  • 感谢您的宝贵意见 :-)

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


【解决方案1】:

如果您查看people.list 的文档,您会发现此方法不再有效。

Google+ People API 列表端点已弃用。考虑改用 Google People API。

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

【讨论】:

  • 我尝试了同样的方法,但它返回了一个错误。 mscorlib.dll 中出现“Google.GoogleApiException”类型的异常,但未在用户代码中处理其他信息:Google.Apis.Requests.RequestError 无法找到 ID 为 people/me [404] 的用户
  • 您使用的是服务帐号吗?让用户在这里登录,确保他们有一个谷歌帐户contacts.google.com
  • 感谢您的回复!是的,我正在使用“PlusService”,我尝试获取活动,它为我创建的相同服务提供了结果,但“人员”中没有任何内容
  • 检查更新我以为你使用了不同的方法。
  • 谢谢!那么有没有其他方法可以获取各个圈子的GooglePlus人员列表。我打算在我的网络应用程序中制作一个“邀请朋友”模块。任何其他建议总是受欢迎的。 :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-29
相关资源
最近更新 更多