【发布时间】: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#代码: