本文整理汇总了C#中OAuthTokens类的典型用法代码示例。如果您正苦于以下问题:C# OAuthTokens类的具体用法?C# OAuthTokens怎么用?C# OAuthTokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthTokens类属于命名空间,在下文中一共展示了OAuthTokens类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetHomeTimeLineAsync
public async Task<IEnumerable<TwitterSchema>> GetHomeTimeLineAsync(OAuthTokens tokens)
{
try
{
var uri = new Uri("https://api.twitter.com/1.1/statuses/home_timeline.json");
var rawResult = await _request.ExecuteAsync(uri, tokens);
var result = JsonConvert.DeserializeObject<TwitterTimeLineItem[]>(rawResult);
return result
.Select(r => new TwitterSchema(r))
.ToList();
}
catch (WebException wex)
{
HttpWebResponse response = wex.Response as HttpWebResponse;
if (response != null)
{
if ((int)response.StatusCode == 429)
{
return GenerateErrorTweet("Too many requests. Please refresh in a few minutes.");
}
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
return GenerateErrorTweet("The keys provided have been revoked or deleted.");
}
}
throw;
}
}
开发者ID:Hackaju,项目名称:App_Hackaju_WP,代码行数:30,代码来源:TwitterProvider.cs
示例2: SearchAsync
/// <summary>
/// Searches Twitter with the the specified query.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="tokens">The tokens. Leave null for unauthenticated request.</param>
/// <param name="options">The options. Leave null for defaults.</param>
/// <returns>
/// A <see cref="TwitterSearchResultCollection"/> instance.
/// </returns>
public static async Task<TwitterResponse<TwitterSearchResultCollection>> SearchAsync(string query, OAuthTokens tokens = null, SearchOptions options = null)
{
if (options == null)
options = new SearchOptions();
return await Core.CommandPerformer.PerformAction(new Twitterizer.Commands.SearchCommand(tokens, query, options));
}
开发者ID:DigitallyBorn,项目名称:Twitterizer3,代码行数:16,代码来源:Search.cs
示例3: SearchAsync
public async Task<IEnumerable<TwitterSchema>> SearchAsync(string hashTag, OAuthTokens tokens)
{
try
{
var uri = new Uri(string.Format("https://api.twitter.com/1.1/search/tweets.json?q={0}", Uri.EscapeDataString(hashTag)));
var rawResult = await _request.ExecuteAsync(uri, tokens);
var result = JsonConvert.DeserializeObject<TwitterSearchResult>(rawResult);
return result.statuses
.Select(r => new TwitterSchema(r))
.ToList();
}
catch (WebException wex)
{
HttpWebResponse response = wex.Response as HttpWebResponse;
if (response != null)
{
if ((int)response.StatusCode == 429)
{
return GenerateErrorTweet("Too many requests. Please refresh in a few minutes.");
}
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
return GenerateErrorTweet("The keys provided have been revoked or deleted.");
}
}
throw;
}
}
开发者ID:Hackaju,项目名称:App_Hackaju_WP,代码行数:30,代码来源:TwitterProvider.cs
示例4: MentionsCommand
/// <summary>
/// Initializes a new instance of the <see cref="MentionsCommand"/> class.
/// </summary>
/// <param name="tokens">The request tokens.</param>
/// <param name="options">The options.</param>
public MentionsCommand(OAuthTokens tokens, TimelineOptions options)
: base(HTTPVerb.GET, "statuses/mentions_timeline.json", tokens, options)
{
if (tokens == null)
{
throw new ArgumentNullException("tokens");
}
}
开发者ID:MrZweistein,项目名称:Twitterizer,代码行数:13,代码来源:MentionsCommand.cs
示例5: HomeTimelineCommand
/// <summary>
/// Initializes a new instance of the <see cref="HomeTimelineCommand"/> class.
/// </summary>
/// <param name="tokens">The request tokens.</param>
/// <param name="optionalProperties">The optional properties.</param>
public HomeTimelineCommand(OAuthTokens tokens, TimelineOptions optionalProperties)
: base(HTTPVerb.GET, "statuses/home_timeline.json", tokens, optionalProperties)
{
if (tokens == null)
{
throw new ArgumentNullException("tokens");
}
}
开发者ID:JohnSmithJS,项目名称:Twitterizer,代码行数:13,代码来源:HomeTimelineCommand.cs
示例6: authTwitter
public OAuthTokens authTwitter(string ConsumerKey, string ConsumerSecret, string AccessToken, string AccessTokenSecret)
{
OAuthTokens tokens = new OAuthTokens();
tokens.ConsumerKey = ConsumerKey;
tokens.ConsumerSecret= ConsumerSecret;
tokens.AccessToken = AccessToken;
tokens.AccessTokenSecret=AccessTokenSecret;
return tokens;
}
开发者ID:jorgtowers,项目名称:TweetBotExample,代码行数:9,代码来源:TweetBot.cs
示例7: ExecuteAsync
public async Task<string> ExecuteAsync(Uri requestUri, OAuthTokens tokens)
{
var request = CreateRequest(requestUri, tokens);
var response = await request.GetResponseAsync();
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
return sr.ReadToEnd();
}
}
开发者ID:Hackaju,项目名称:App_Hackaju_WP,代码行数:10,代码来源:OAuthRequest.cs
示例8: TwitterStreaming
public TwitterStreaming(OAuthTokens Tokens, string TwitterAccount, Decimal TwitterAccountID)
{
this.TwitterAccount = TwitterAccount;
this.TwitterAccountID = TwitterAccountID;
this.Stream = new Stream(Tokens, string.Format("MetroTwit/{0}", (object) ((object) System.Windows.Application.ResourceAssembly.GetName().Version).ToString()), (StreamOptions) new UserStreamOptions()
{
AllReplies = App.AppState.Accounts[this.TwitterAccountID].Settings.AllReplies
});
this.Stopped = true;
this.StartStream();
}
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:11,代码来源:TwitterStreaming.cs
示例9: CreateRequest
private static WebRequest CreateRequest(Uri requestUri, OAuthTokens tokens)
{
var requestBuilder = new OAuthRequestBuilder(requestUri, tokens);
var request = (HttpWebRequest)WebRequest.Create(requestBuilder.EncodedRequestUri);
request.UseDefaultCredentials = true;
request.Method = OAuthRequestBuilder.Verb;
request.Headers["Authorization"] = requestBuilder.AuthorizationHeader;
return request;
}
开发者ID:Hackaju,项目名称:App_Hackaju_WP,代码行数:12,代码来源:OAuthRequest.cs
示例10: Search
/// <summary>
/// Searches Twitter with the the specified query.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="query">The query.</param>
/// <param name="options">The options.</param>
/// <returns>
/// A <see cref="TwitterSearchResultCollection"/> instance.
/// </returns>
public static TwitterResponse<TwitterSearchResultCollection> Search(OAuthTokens tokens, string query, SearchOptions options)
{
if (options == null)
options = new SearchOptions();
Commands.SearchCommand command = new Twitterizer.Commands.SearchCommand(tokens, query, options);
TwitterResponse<TwitterSearchResultCollection> results =
Core.CommandPerformer.PerformAction(command);
return results;
}
开发者ID:MrZweistein,项目名称:Twitterizer,代码行数:21,代码来源:TwitterSearch.cs
示例11: sendTweet
public string sendTweet(string tweet, OAuthTokens tokens)
{
StatusUpdateOptions options = new StatusUpdateOptions() { UseSSL = true, APIBaseAddress = "http://api.twitter.com/1.1/" };
TwitterResponse<TwitterStatus> response = TwitterStatus.Update(tokens, tweet, options);
if (response.Result == RequestResult.Success)
{
return "bueno ";
}
else
{
return "malo ";
}
}
开发者ID:jorgtowers,项目名称:TweetBotExample,代码行数:13,代码来源:TweetBot.cs
示例12: UserTimelineCommand
/// <summary>
/// Initializes a new instance of the <see cref="UserTimelineCommand"/> class.
/// </summary>
/// <param name="tokens">The request tokens.</param>
/// <param name="options">The options.</param>
public UserTimelineCommand(OAuthTokens tokens, UserTimelineOptions options)
: base(HTTPVerb.GET, "statuses/user_timeline.json", tokens, options)
{
if (tokens == null && options == null)
{
throw new ArgumentException("You must supply either OAuth tokens or identify a user in the TimelineOptions class.");
}
if (options != null && tokens == null && string.IsNullOrEmpty(options.ScreenName) && options.UserId <= 0)
{
throw new ArgumentException("You must specify a user's screen name or id for unauthorized requests.");
}
}
开发者ID:JohnSmithJS,项目名称:Twitterizer,代码行数:18,代码来源:UserTimelineCommand.cs
示例13: OAuthRequestBuilder
public OAuthRequestBuilder(Uri requestUri, OAuthTokens tokens)
{
RequestUriWithoutQuery = new Uri(requestUri.AbsoluteWithoutQuery());
QueryParams = requestUri.GetQueryParams()
.Select(p => new OAuthParameter(p.Key, p.Value))
.ToList();
EncodedRequestUri = GetEncodedUri(requestUri, QueryParams);
Version = new OAuthParameter("oauth_version", "1.0");
Nonce = new OAuthParameter("oauth_nonce", GenerateNonce());
Timestamp = new OAuthParameter("oauth_timestamp", GenerateTimeStamp());
SignatureMethod = new OAuthParameter("oauth_signature_method", "HMAC-SHA1");
ConsumerKey = new OAuthParameter("oauth_consumer_key", tokens["ConsumerKey"]);
ConsumerSecret = new OAuthParameter("oauth_consumer_secret", tokens["ConsumerSecret"]);
Token = new OAuthParameter("oauth_token", tokens["AccessToken"]);
TokenSecret = new OAuthParameter("oauth_token_secret", tokens["AccessTokenSecret"]);
}
开发者ID:glebanych,项目名称:hromadske-windows,代码行数:19,代码来源:OAuthRequestBuilder.cs
示例14: ReportUser
/// <summary>
/// Blocks the user and reports them for spam/abuse.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="screenName">The user's screen name.</param>
/// <returns>The user details.</returns>
public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, string screenName)
{
return ReportUser(tokens, screenName);
}
开发者ID:zippy1981,项目名称:Twitterizer,代码行数:10,代码来源:TwitterSpam.cs
示例15: ShowAsync
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="Common"]/*'/>
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="ByIDWithTokensAndOptions"]/*'/>
public static async Task<TwitterResponse<User>> ShowAsync(decimal id, OAuthTokens tokens = null, OptionalProperties options = null)
{
return await Core.CommandPerformer.PerformAction(new Commands.ShowUserCommand(tokens, id, string.Empty, options));
}
开发者ID:jorgtowers,项目名称:Twitterizer3,代码行数:6,代码来源:Users.cs
示例16: TwitterStream
/// <summary>
/// Initializes a new instance of the <see cref="TwitterStream"/> class.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="userAgent">The useragent string which shall include the version of your client.</param>
/// <param name="streamoptions">The stream or user stream options to intially use when starting the stream.</param>
public TwitterStream(OAuthTokens tokens, string userAgent, StreamOptions streamoptions)
{
#if !SILVERLIGHT // No non-silverlight user-agent as Assembly.GetName() isn't supported and setting the request.UserAgent is also not supported.
if (string.IsNullOrEmpty(userAgent))
{
this.UserAgent = string.Format(
CultureInfo.InvariantCulture,
"Twitterizer/{0}",
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
}
else
{
this.UserAgent = string.Format(
CultureInfo.InvariantCulture,
"{0} (via Twitterizer/{1})",
userAgent,
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
}
#endif
this.Tokens = tokens;
if (streamoptions != null)
this.StreamOptions = streamoptions;
}
开发者ID:vgheri,项目名称:TwitterSearch,代码行数:30,代码来源:TwitterStream.cs
示例17: Follow
/// <summary>
/// Enables device notifications for updates from the specified user. Returns the specified user when successful.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="screenName">The user's screen name.</param>
/// <returns></returns>
public static TwitterResponse<TwitterUser> Follow(OAuthTokens tokens, string screenName)
{
return Follow(tokens, screenName, null);
}
开发者ID:JohnSmithJS,项目名称:Twitterizer,代码行数:10,代码来源:TwitterNotification.cs
示例18: ShowAsync
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="Common"]/*'/>
/// <include file='TwitterUser.xml' path='TwitterUser/Show[@name="ByUsernameWithTokensAndOptions"]/*'/>
public static async Task<TwitterResponse<TwitterUser>> ShowAsync(string username, OAuthTokens tokens = null, OptionalProperties options = null)
{
return await Core.CommandPerformer.PerformAction(new Commands.ShowUserCommand(tokens, 0, username, options));
}
开发者ID:DigitallyBorn,项目名称:Twitterizer3,代码行数:6,代码来源:Users.cs
示例19: OAuthWithAuthorizationCode
/// <summary>
/// Initializes a new instance of the OAuthWithAuthorizationCode class.
/// </summary>
/// <param name="clientId">
/// The client identifier corresponding to your registered application.
/// </param>
/// <param name="optionalClientSecret">
/// The client secret corresponding to your registered application, or null if your app is a desktop or mobile app.
/// </param>
/// <param name="redirectionUri">
/// The URI to which the user of the app will be redirected after receiving user consent.
/// </param>
/// <param name="refreshToken">
/// The refresh token that should be used to request an access token.
/// </param>
/// <remarks>
/// <para>
/// For more information about using a client identifier for authentication, see
/// <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-3.1">Client Password Authentication section of the OAuth 2.0 spec</see>
/// </para>
/// <para>
/// For web applications, redirectionUri must be within the same domain of your registered application.
/// For more information, see <see href="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1.1">Redirection Uri section of the OAuth 2.0 spec</see>.
/// </para>
/// </remarks>
protected OAuthWithAuthorizationCode(string clientId, string optionalClientSecret, Uri redirectionUri, string refreshToken)
: this(clientId, optionalClientSecret, redirectionUri, new LiveComOAuthService())
{
if (refreshToken == null)
{
throw new ArgumentNullException("refreshToken");
}
OAuthTokens = new OAuthTokens(null, 0, refreshToken);
}
开发者ID:moinahmed,项目名称:BingAds-dotNet-SDK,代码行数:35,代码来源:OAuthWithAuthorizationCode.cs
示例20: FriendsIdsAsync
/// <summary>
/// Returns the numeric IDs for every user the specified user is friends with.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="options">The options. Leave null for defaults.</param>
/// <returns>
/// A <see cref="TwitterListCollection"/> instance.
/// </returns>
public static async Task<TwitterResponse<UserIdCollection>> FriendsIdsAsync(OAuthTokens tokens, UsersIdsOptions options = null)
{
return await Core.CommandPerformer.PerformAction(new Commands.FriendsIdsCommand(tokens, options));
}
开发者ID:jitendraagrawal1,项目名称:Twitterizer3,代码行数:12,代码来源:FriendsFollowers.cs
注:本文中的OAuthTokens类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论