我正在尝试学习 google Person api 来开发应用程序。
我正在使用谷歌 api 教程 https://developers.google.com/people/v1/getting-started
using Google;
using Google.Apis.Auth.OAuth2;
using Google.Apis.People.v1;
using Google.Apis.People.v1.Data;
using Google.Apis.Services;
...
static void Main(string[] args)
{
// Create OAuth credential.
UserCredential credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "CLIENT_ID",
ClientSecret = "CLIENT_SECRET"
},
new[] { "profile",
"https://www.googleapis.com/auth/contacts.readonly" },
"me",
CancellationToken.None).Result;
// Create the service.
var peopleService = new PeopleService (new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "APP_NAME",
});
PeopleResource.ConnectionsResource.ListRequest peopleRequest =
peopleService.People.Connections.List("people/me");
peopleRequest.PersonFields = "names,emailAddresses";
ListConnectionsResponse connectionsResponse = peopleRequest.Execute();
IList<Person> connections = connectionsResponse.Connections;
当我在教程中使用示例脚本时,信息被检索到了。
我使用 c# 在 Visual Studio 中创建了一个灵魂。我添加了对所有需要的 google api 的引用。
该项目无法编译,因为 PersonFields 无法识别。成功的动作需要此属性