本文整理汇总了C#中Api.Contacts方法的典型用法代码示例。如果您正苦于以下问题:C# Api.Contacts方法的具体用法?C# Api.Contacts怎么用?C# Api.Contacts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api.Contacts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var api = new Api(Settings.Default.DomainKey, Settings.Default.DomainPassword);
var consent = api.Consent(ContactSource.Gmail);
Process.Start(consent.Url);
bool complete = false;
while (!complete)
{
var events = api.Events(consent.ImportId);
foreach (var item in events.Events)
Console.WriteLine("{0}-{1}", item.Type, item.Status);
complete = events.IsComplete;
}
var contacts = api.Contacts(consent.ImportId);
foreach (var item in contacts.Contacts)
Console.WriteLine("{1}, {0} ({2})", item.FirstName, item.LastName, item.EmailAddresses.FirstOrDefault());
}
示例2: GetFriendsEmail
public List<string> GetFriendsEmail(string mailType)
{
List<string> lstEmail = new List<string>();
try
{
try
{
//Client ID 767237347813-0decm2cgu5sab8pr50rr0hmerh9e0q73.apps.googleusercontent.com
//Client secret DQNCzBuiwo0U58rkAbo38Jvs
string domainKey = ConfigurationSettings.AppSettings["DomainKey"];
string domainPassword = ConfigurationSettings.AppSettings["DomainPassword"];
//var api = new Api(Settings.Default.DomainKey, Settings.Default.DomainPassword);
var api = new Api(domainKey, domainPassword);
//var api = new Api("QHBFU6D43BDCTQJT3XVZ", "vtFIAaMaGkSYVZMY");
//var consent = api.Consent(ContactSource.Gmail);
ConsentResponse consent = null;
if (mailType == "gmail")
{
consent = api.Consent(ContactSource.Gmail);
}
if (mailType == "yahoo")
{
consent = api.Consent(ContactSource.Yahoo);
}
if (mailType == "hotmail")
{
consent = api.Consent(ContactSource.WindowsLive);
}
//Process.Start("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=767237347813-0decm2cgu5sab8pr50rr0hmerh9e0q73.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds&redirect_uri=https%3A%2F%2Fapi.cloudsponge.com%2Fauth&state=import_id%3D30938548");
Process.Start(consent.Url);
bool complete = false;
while (!complete)
{
var events = api.Events(consent.ImportId);
foreach (var item in events.Events)
Console.WriteLine("{0}-{1}", item.Type, item.Status);
complete = events.IsComplete;
}
var contacts = api.Contacts(consent.ImportId);
foreach (var item in contacts.Contacts)
{
try
{
Console.WriteLine("{1}, {0} ({2})", item.FirstName, item.LastName, item.EmailAddresses.FirstOrDefault());
string emailAddresses = item.FirstName + "<~>" + item.LastName + "<~>" + item.EmailAddresses.FirstOrDefault();
lstEmail.Add(emailAddresses);
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
}
}
catch (Exception)
{
}
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
return lstEmail;
}
示例3: GetContext
private static List<string> GetContext(Api api, ConsentResponse consent)
{
List<string> lstEmail = new List<string>();
try
{
bool complete = false;
while (!complete)
{
var events = api.Events(consent.ImportId);
foreach (var item in events.Events)
Console.WriteLine("{0}-{1}", item.Type, item.Status);
complete = events.IsComplete;
}
var contacts = api.Contacts(consent.ImportId);
foreach (var item in contacts.Contacts)
{
try
{
Console.WriteLine("{1}, {0} ({2})", item.FirstName, item.LastName, item.EmailAddresses.FirstOrDefault());
string emailAddresses = item.FirstName + "<~>" + item.LastName + "<~>" + item.EmailAddresses.FirstOrDefault();
lstEmail.Add(emailAddresses);
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
return lstEmail;
}