逐页获取Google个联系人页面c#
Get the Google contacts page by page c#
我开发了读取 google 联系人的应用程序。我可以阅读联系人,但我不确定如何逐页阅读。在这里,我附上了我的示例代码。
GoogleCredential credential = GoogleCredential.FromJson(gCredJson)
.CreateScoped(Scopes)
.CreateWithUser(usrName);
string token = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync().ConfigureAwait(true);
获取联系人
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.AccessToken = token;
RequestSettings settings = new RequestSettings("mailApp", parameters);
settings.AutoPaging = true;
settings.Maximum = 2;
settings.PageSize = 2;
ContactsRequest cr = new ContactsRequest(settings);
Feed<Contact> f = cr.GetContacts("myemail@gmail.com");
foreach (Contact c in f.Entries)
{
Console.WriteLine(c.Name.FullName);
}
上面的代码给我联系人。但是,我不知道如何处理下一页。如果有人对此提供帮助,我们将不胜感激。
您是否考虑过使用 ContactsQuery?请检查示例 #2。
var contactsPerQuery = 50;
var maxTotal = 32000;
ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
query.NumberToRetrieve = contactsPerQuery;
for (int index = 0; index < maxTotal; index += contactsPerQuery)
{
query.StartIndex = index;
Feed<Contact> feed = cr.Get<Contact>(query);
//display contacts from feed.Entries
....
}
我开发了读取 google 联系人的应用程序。我可以阅读联系人,但我不确定如何逐页阅读。在这里,我附上了我的示例代码。
GoogleCredential credential = GoogleCredential.FromJson(gCredJson)
.CreateScoped(Scopes)
.CreateWithUser(usrName);
string token = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync().ConfigureAwait(true);
获取联系人
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.AccessToken = token;
RequestSettings settings = new RequestSettings("mailApp", parameters);
settings.AutoPaging = true;
settings.Maximum = 2;
settings.PageSize = 2;
ContactsRequest cr = new ContactsRequest(settings);
Feed<Contact> f = cr.GetContacts("myemail@gmail.com");
foreach (Contact c in f.Entries)
{
Console.WriteLine(c.Name.FullName);
}
上面的代码给我联系人。但是,我不知道如何处理下一页。如果有人对此提供帮助,我们将不胜感激。
您是否考虑过使用 ContactsQuery?请检查示例 #2。
var contactsPerQuery = 50;
var maxTotal = 32000;
ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
query.NumberToRetrieve = contactsPerQuery;
for (int index = 0; index < maxTotal; index += contactsPerQuery)
{
query.StartIndex = index;
Feed<Contact> feed = cr.Get<Contact>(query);
//display contacts from feed.Entries
....
}