本文整理汇总了C#中OAuthInfo类的典型用法代码示例。如果您正苦于以下问题:C# OAuthInfo类的具体用法?C# OAuthInfo怎么用?C# OAuthInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthInfo类属于命名空间,在下文中一共展示了OAuthInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TwitPicUploader
public TwitPicUploader(string key, OAuthInfo oauth)
{
APIKey = key;
AuthInfo = oauth;
TwitPicUploadType = TwitPicUploadType.UPLOAD_IMAGE_ONLY;
ShowFull = false;
TwitPicThumbnailMode = TwitPicThumbnailType.Thumb;
}
示例2: GetAccountInfo
private AccountInfo GetAccountInfo(OAuthInfo oauth)
{
var uri = new Uri("https://api.dropbox.com/1/account/info");
var client = GetDropboxClient(HttpMethod.Get, uri, oauth);
var response = client.GetAsync(uri.PathAndQuery).Result.EnsureSuccessful();
using (var reader = new JsonTextReader(new StreamReader(response.Content.ReadAsStreamAsync().Result)))
{
JsonSerializer serializer = new JsonSerializer();
return serializer.Deserialize<AccountInfo>(reader);
}
}
示例3: Tweet
public void Tweet(string text)
{
string[] creds = File.ReadAllLines("./config.cfg");
OAuthInfo TInfo = new OAuthInfo();
TInfo.ConsumerKey = creds[0];
TInfo.ConsumerSecret = creds[1];
TInfo.AccessToken = creds[2];
TInfo.AccessSecret = creds[3];
TinyTwitter.TinyTwitter Manager = new TinyTwitter.TinyTwitter(TInfo);
Manager.UpdateStatus(text.Replace("\n\n",""));
}
示例4: GetDeltaInfo
private DeltaInfo GetDeltaInfo(OAuthInfo oauth, string cursor = null)
{
Uri uri;
HttpClient client;
if (!String.IsNullOrEmpty(cursor))
{
uri = new Uri("https://api.dropbox.com/1/delta/?cursor=" + cursor);
client = GetDropboxClient(HttpMethod.Post, uri, oauth, new KeyValuePair<string, string>("cursor", cursor));
}
else
{
uri = new Uri("https://api.dropbox.com/1/delta");
client = GetDropboxClient(HttpMethod.Post, uri, oauth);
}
var response = client.PostAsync(uri.PathAndQuery, null).Result.EnsureSuccessful();
using (var reader = new JsonTextReader(new StreamReader(response.Content.ReadAsStreamAsync().Result)))
{
JsonSerializer serializer = new JsonSerializer();
return new DeltaInfo(serializer.Deserialize<JObject>(reader));
}
}
示例5: Main
static void Main(string[] args)
{
//OAuthInfo myOAuth = new OAuthInfo();
//myOAuth.ConsumerKey = "";
//myOAuth.ConsumerSecret = "";
//myOAuth.AccessSecret = "";
//myOAuth.AccessToken = "";
//var myOauth = new
//TinyTwitter TT = new TinyTwitter(new OAuthInfo());
//IEnumerable<Tweet> mytimneline = TT.GetHomeTimeline(null, 2);
var oauth = new OAuthInfo
{
AccessToken = "21985278-dud1wSertHCQYTUK5ta5AA0ciqWB31ZsT8Dt8DJg",
AccessSecret = "yPDp2TTOOhQj6XDxX7P5TxmNtHZcQ6sJumth8DVzRk",
ConsumerKey = "tedRo766zL7mr7TKZkOugA",
ConsumerSecret = "WREOp5SZ71EtLCt3T4RboUv1IrkUpPkCpcBxkAGk8"
};
var twitter = new TinyTwitter(oauth);
//// Update status, i.e, post a new tweet
//twitter.UpdateStatus("I'm tweeting from C#");
// Get home timeline tweets
var tweets = twitter.GetUserTimeline(null, 5);
//twitter.UpdateStatus("First tweet from my program");
// twitter.UpdateStatus("First tweet from my program");
foreach (var tweet in tweets)
Console.WriteLine("{0}: {1}: {2}", tweet.UserName, tweet.Text, tweet.Id);
Console.ReadKey();
}
示例6: Jira
public Jira(string jiraBaseAddress, OAuthInfo oauth, string jiraIssuePrefix = null)
{
_jiraBaseAddress = jiraBaseAddress;
AuthInfo = oauth;
_jiraIssuePrefix = jiraIssuePrefix;
InitUris();
}
示例7: GetAccessToken
protected bool GetAccessToken(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET)
{
return GetAccessTokenEx(accessTokenURL, authInfo, httpMethod) != null;
}
示例8: TwitterTweetForm
public TwitterTweetForm(OAuthInfo oauth)
: this()
{
AuthInfo = oauth;
}
示例9: Main
public static void Main(string[] args)
{
//Load config
XmlData config;
try
{
config=new XmlData("tweetstatus.xml");
}
catch(Exception e)
{
Console.WriteLine("Konfiguration konnte nicht gelesen werden.");
Console.WriteLine(e.ToString());
return;
}
string miscCheckCertificates=config.GetElementAsString("xml.misc.checkcertificates");
if(miscCheckCertificates.ToLower()=="false")
{
//Disable certificate check
ServicePointManager.ServerCertificateValidationCallback=delegate
{
return true;
};
}
string apiToken=config.GetElementAsString("xml.api.token");
string apiUrl=config.GetElementAsString("xml.api.url");
string twitterConsumerKey=config.GetElementAsString("xml.twitter.consumerkey");
string twitterConsumerSecret=config.GetElementAsString("xml.twitter.consumersecret");
string twitterAccessToken=config.GetElementAsString("xml.twitter.accesstoken");
string twitterAccessTokenSecret=config.GetElementAsString("xml.twitter.accesstokensecret");
//Create twitter token
OAuthInfo token=null;
if(twitterAccessToken==""||twitterAccessTokenSecret=="")
{
Console.WriteLine("Set access token in config file");
return;
}
else
{
token=new OAuthInfo {
AccessToken=twitterAccessToken,
AccessSecret=twitterAccessTokenSecret,
ConsumerKey=twitterConsumerKey,
ConsumerSecret=twitterConsumerSecret
};
}
//Check status database
Console.WriteLine("Check status database");
//Database
RestClient client=new RestClient(apiUrl);
string parameters=String.Format("entities/?token={0}", apiToken);
string value=client.Request(parameters);
int entityCount=Convert.ToInt32(value);
Console.WriteLine("Entity count from api: {0}", entityCount);
//Check status file and tweet if nessesary
//Load known entries
string entryFile="status.txt";
Entry oldStatus=new Entry(0);
if(File.Exists(entryFile))
{
oldStatus=new Entry(File.ReadAllLines(entryFile)[0]);
}
Entry newStatus=new Entry(entityCount);
if(oldStatus!=newStatus)
{
//Tweet
DateTime now=DateTime.Now;
string datetimeHash="#"+CRC16.ComputeChecksum(BitConverter.GetBytes(now.Ticks)).ToString("x4");
string statusGreen=String.Format("Der Hackerspace ist besetzt ({0}:{1:00} Uhr) und kann besucht werden. #status {2}", now.Hour, now.Minute, datetimeHash);
string statusYellow="";
string statusRed=String.Format("Der Hackerspace ist nicht mehr besetzt ({0}:{1:00} Uhr). #status {2}", now.Hour, now.Minute, datetimeHash);
string tweetText="";
if(newStatus.EntityCount==0)
{
tweetText=statusRed;
}
else
{
if(oldStatus.EntityCount>0)
{
Console.WriteLine("Update not necessary.");
//.........这里部分代码省略.........
示例10: TwitterAuthClear
private void TwitterAuthClear()
{
if (CheckTwitterAccounts())
{
OAuthInfo oauth = new OAuthInfo();
OAuthInfo oauth2 = GetSelectedTwitterAccount();
if (oauth2 != null)
{
oauth.Description = oauth2.Description;
}
Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = oauth;
}
}
示例11: CopyAuthOpen
public void CopyAuthOpen()
{
try
{
OAuthInfo oauth = new OAuthInfo(APIKeys.CopyConsumerKey, APIKeys.CopyConsumerSecret);
string url = new Copy(oauth).GetAuthorizationURL();
if (!string.IsNullOrEmpty(url))
{
Config.CopyOAuthInfo = oauth;
URLHelpers.OpenURL(url);
DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is opened: " + url);
}
else
{
DebugHelper.WriteLine("CopyAuthOpen - Authorization URL is empty.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例12: TwitterAuthOpen
public void TwitterAuthOpen()
{
if (CheckTwitterAccounts())
{
OAuthInfo acc = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret);
Twitter twitter = new Twitter(acc);
string url = twitter.GetAuthorizationURL();
if (!string.IsNullOrEmpty(url))
{
acc.Description = Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount].Description;
Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = acc;
ucTwitterAccounts.pgSettings.SelectedObject = acc;
URLHelpers.OpenURL(url);
btnTwitterLogin.Enabled = true;
}
}
}
示例13: Twitter
public Twitter(OAuthInfo oauth)
{
AuthInfo = oauth;
}
示例14: GetAccessTokenEx
protected NameValueCollection GetAccessTokenEx(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET)
{
if (string.IsNullOrEmpty(authInfo.AuthToken) || string.IsNullOrEmpty(authInfo.AuthSecret))
{
throw new Exception("Auth infos missing. Open Authorization URL first.");
}
string url = OAuthManager.GenerateQuery(accessTokenURL, null, httpMethod, authInfo);
string response = SendRequest(httpMethod, url);
if (!string.IsNullOrEmpty(response))
{
return OAuthManager.ParseAccessTokenResponse(response, authInfo);
}
return null;
}
示例15: Copy
public Copy(OAuthInfo oauth)
{
AuthInfo = oauth;
}