本文整理汇总了C#中Api.Consent方法的典型用法代码示例。如果您正苦于以下问题:C# Api.Consent方法的具体用法?C# Api.Consent怎么用?C# Api.Consent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api.Consent方法的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: GetFriendsEmail
public string GetFriendsEmail(string mailType)
{
string res = string.Empty;
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"];
string domainKey = "BTUU28Y8FTW4UTXL44B8";
string domainPassword = "Yes6cLblk3lf4jWt";
//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);
try
{
//new Thread(() =>
//{
// GetContext(lstEmail, api, consent);
//}).Start();
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
try
{
// Response.Write(consent.Url);
//Response.Redirect(consent.Url);
//Response.Redirect(consent.Url, true);
//Server.Transfer(consent.Url);
///open url in new tab using javascript
//string url = "https://www.google.co.in";
////string s = "window.open('" + url + "', '_blank', 'width=300,height=100,left=100,top=100,resizable=yes');";
//string s = "window.open('" + url + "', '_blank');";
//ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
Session["api"] = api;
Session["consent"] = consent;
//Response.Write("Successcloudspongeseperator");
// Response.Write(consent.Url);
//Response.Write("http://www.google.com");
res=consent.Url;
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
return res;
//.........这里部分代码省略.........