c# - 逐页获取谷歌联系人c#
问题描述
我开发了应用程序来阅读谷歌联系人。我可以阅读联系人,但我不确定如何逐页进行。在这里,我附上了我的示例代码。
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
....
}
推荐阅读
- java - 不仅执行 main 方法(Java)是什么意思?
- python - 使用 .map 或类似文件根据特定行和列中的值创建 Pandas 列
- google-cloud-dataflow - 在 Google Dataflow 中查看作业图大小
- sql - 如何比较 SQL Server 中的 2 个字符串,如果有任何大小写差异,则不应为真
- javascript - 快速请求中止
- azure - 是否有等效于“az rest”的 PowerShell?
- java - 使用属性中的版本时 Maven 未解决的参考
- git - 如何分别提交文件夹A和文件B(在文件夹A中)?
- c# - 在测试项目上解析 DbContext 会返回带有错误 connectionString 的 DbContext
- ibm-integration-bus - IBM App Connect Enterprise - 聚合组节点结果