【问题标题】:Google plus language programming using people.list使用 people.list 进行 Google plus 语言编程
【发布时间】:2013-03-21 14:11:38
【问题描述】:

作为一名新研究人员,我正在尝试获取有关 G+ 上人与人之间关系的信息。我想获取其他人的圈子列表以用于某些研究目的。似乎 G+ API 提供了一个网络版本来使用 people.list 和 OAuth2 令牌。我的问题是,people.list 是否支持 c#、java 等编程语言?我用 c# 试过,但它似乎被服务器阻止了。

有没有办法在 c#、java 等中应用 people.list ?如果有,有样品吗?或者有人提供一些开放代码来完成类似的功能?

非常感谢。

以下是我的相关c#代码:

var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description)
                {
                    ClientIdentifier = credentials.ClientId,
                    ClientSecret = credentials.ClientSecret
                };
            var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);


        var servicelist = new PlusService(new BaseClientService.Initializer()
        {
            Authenticator = auth
        });

        string userId = "********************";
        PeopleResource.ListRequest circle = servicelist.People.List(userId, new PeopleResource.Collection());
        circle.MaxResults = 5;
        PeopleFeed danielfeed = circle.Fetch();

    private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
    {
        IAuthorizationState state = new AuthorizationState(new[] { TasksService.Scopes.Tasks.GetStringValue() });
        state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
        Uri authUri = arg.RequestUserAuthorization(state);

        Process.Start(authUri.ToString());
        Console.Write("  Authorization Code: ");
        string authCode = Console.ReadLine();
        Console.WriteLine();

        return arg.ProcessUserAuthorization(authCode, state);
    }
}

程序在“PeopleFeed danielfeed = circle.Fetch();”处出错我想我已经通过变量“auth”将 OAuth 令牌传递给 people.list 函数。能给我一些建议吗?

【问题讨论】:

  • Google 不会阻止语言,它会阻止无效请求。如果您显示一些代码,也许我们可以找到问题所在?另外,我对“people.list”不熟悉,你能详细说明一下吗?
  • 是的,下面是我的相关c#代码:

标签: c# list oauth geometry


【解决方案1】:

谷歌的People:list API's documentation is here。整个 API 为RESTful,不屏蔽任何语言。

您可以使用 C#,并且只需要学习如何在 C# 中使用 REST API。您将要使用的 C# 类是 HttpClient 类。 here 有很好的文档记录,并且有很多在线教程,以及这里的 SO。

【讨论】:

    猜你喜欢
    • 2011-11-22
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-16
    • 1970-01-01
    • 2012-01-17
    • 1970-01-01
    相关资源
    最近更新 更多