예제 #1
0
 /// <summary>
 /// The async implementation of <see cref="EndSession"/>
 /// </summary>
 public static void EndSessionAsync(AsyncCallback<UserInfo> callback)
 {
     var requester = new OAuthHttpGet(APIUri.EndSession);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #2
0
 /// <summary>
 /// The async implementation of <see cref="GetTrendStatuses"/>
 /// </summary>
 public static void GetTrendStatusesAsync(AsyncCallback<Statuses> callback, string trendName)
 {
     ValidateArgument(trendName, "trendName");
     var requester = new OAuthHttpGet(APIUri.GetTrendStatuses);
     requester.Params.Add("trend_name", RFC3986Encoder.UrlEncode(trendName));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #3
0
        /// <summary>
        /// The async implementation of <see cref="GetEmotions"/>
        /// </summary>
        public static void GetEmotionsAsync(AsyncCallback<Emotions> callback, EmotionType emotionType = EmotionType.Image, string language = "")
        {
            var requester = new OAuthHttpGet(APIUri.GetEmotions);
            if (emotionType != EmotionType.Image)
            {
                var eType = string.Empty;
                switch (emotionType)
                {
                    case EmotionType.Image:
                        eType = "face";
                        break;
                    case EmotionType.Magic:
                        eType = "ani";
                        break;
                    case EmotionType.Cartoon:
                        eType = "cartoon";
                        break;
                    default:
                        eType = "face";
                        break;
                }
                requester.Params.Add(new ParamPair("type", eType));
            }

            if (!string.IsNullOrEmpty(language))
                requester.Params.Add(new ParamPair("language", language));

            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                ProcessAsyncCallbackResponse(result, callback, EncodeXmlCharsPreprocess);
            });
        }
예제 #4
0
        /// <summary>
        /// The async implementation of <see cref="GetShortUrlSharedStatuses"/>
        /// </summary>
        public static void GetShortUrlSharedStatusesAsync(AsyncCallback<Statuses> callback, string shortUrl, long? sinceID = null, long? maxID = null, int? page = null, int? count = null)
        {
            ValidateArgument(shortUrl, "shortUrl");
            var requester = new OAuthHttpGet(APIUri.GetShortUrlSharedStatuses);
            requester.Params.Add("url_short", shortUrl);
            ConstructPagedRecordsParams(requester.Params, sinceID, maxID, count, page);
            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                Func<string, string> preprocess = delegate(string response)
                {
                    response = response.Replace("<url>", "");
                    response = response.Replace("</url>", "");
                    response = response.Replace("<share_statuses>", "<statuses>");
                    response = response.Replace("</share_statuses>", "</statuses>");

                    response = Regex.Replace(response, "<url_short>(.+?)</url_short>", "");

                    return response;
                };

                ProcessAsyncCallbackResponse(result, callback, preprocess);
            });
        }
예제 #5
0
        /// <summary>
        /// The async implementation of <see cref="GetUserStatuses"/>
        /// </summary>
        public static void GetUserStatusesAsync(AsyncCallback<Statuses> callback, long? userID = null, long? sinceID = null, long? maxID = null, int? page = null, int? count = null,
            StatusType feature = StatusType.All, bool currentAppOnly = false)
        {
            var requester = new OAuthHttpGet(APIUri.UserTimeline);
            if(userID.HasValue)
                requester.Params.Add(new ParamPair("user_id", userID.Value.ToString(InvariantCulture)));

            ConstructPagedRecordsParams(requester.Params, sinceID, maxID, page, count);
            if (feature != StatusType.All)
                requester.Params.Add(new ParamPair("feature", ((int)feature).ToString(InvariantCulture)));
            if(currentAppOnly)
                requester.Params.Add(new ParamPair("base_app", "1"));
            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                ProcessAsyncCallbackResponse(result, callback);
            });
        }
예제 #6
0
 /// <summary>
 /// The async implementation of <see cref="ResetCounter"/>
 /// </summary>
 public static void ResetCounterAsync(VoidAsyncCallback callback, CounterType counterType)
 {
     var requester = new OAuthHttpGet(APIUri.ResetCounter);
     requester.Params.Add(new ParamPair("type", ((int)counterType).ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackVoidResponse(result, callback);
     });
 }
예제 #7
0
 /// <summary>
 /// The async implementation of <see cref="GetFriendshipInfo"/>
 /// </summary>
 public static void GetFriendshipInfoAsync(AsyncCallback<RelationshipInfo> callback, long targetUserID, long? sourceUserID = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetFriendshipInfo);
     if(sourceUserID.HasValue)
         requester.Params.Add(new ParamPair("source_id", sourceUserID.Value.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("target_id", targetUserID.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #8
0
 /// <summary>
 /// The async implementation of <see cref="GetUserInfo"/>
 /// </summary>
 public static void GetUserInfoAsync(AsyncCallback<UserInfo> callback, string screenName)
 {
     ValidateArgument(screenName, "screenName");
     var requester = new OAuthHttpGet(string.Format("{0}.xml", APIUri.GetUserInfo));
     requester.Params.Add(new ParamPair("screen_name", RFC3986Encoder.UrlEncode(screenName)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #9
0
 /// <summary>
 /// The async implementation of <see cref="GetFollowingUserIDs"/>
 /// </summary>
 public static void GetFollowingUserIDsAsync(AsyncCallback<UserIDs> callback, long? userID = null, int? cursor = null, int? count = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetFollowingUserIDs);
     if (userID.HasValue)
         requester.Params.Add(new ParamPair("user_id", userID.Value.ToString(InvariantCulture)));
     if (cursor.HasValue)
         requester.Params.Add(new ParamPair("cursor", cursor.Value.ToString(InvariantCulture)));
     if (count.HasValue)
         requester.Params.Add(new ParamPair("count", count.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #10
0
 /// <summary>
 /// The async implementation of <see cref="GetFriends"/>
 /// </summary>
 public static void GetFriendsAsync(AsyncCallback<Users> callback, long? userID = null, string screenName = null, int? cursor = null, int? count = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetFriends);
     if (userID.HasValue)
         requester.Params.Add(new ParamPair("user_id", userID.Value.ToString(InvariantCulture)));
     if (!string.IsNullOrEmpty(screenName))
         requester.Params.Add(new ParamPair("screen_Name", RFC3986Encoder.UrlEncode(screenName)));
     if (cursor.HasValue)
         requester.Params.Add(new ParamPair("cursor", cursor.Value.ToString(InvariantCulture)));
     if (count.HasValue)
         requester.Params.Add(new ParamPair("count", count.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #11
0
 /// <summary>
 /// The async implementation of <see cref="GetFavorites"/>
 /// </summary>
 public static void GetFavoritesAsync(AsyncCallback<Statuses> callback, int? page = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetFavorites);
     if (page.HasValue)
         requester.Params.Add(new ParamPair("page", page.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #12
0
 /// <summary>
 /// The async implementation of <see cref="GetCountersOfCommentNForward"/>
 /// </summary>
 public static void GetCountersOfCommentNForwardAsync(AsyncCallback<Counters> callback, long[] statusIDs)
 {
     ValidateArgument(statusIDs, "statusIDs");
     var requester = new OAuthHttpGet(APIUri.GetCountersOfCommentNForward);
     var statusIDsBuilder = new StringBuilder();
     for (int i = 0; i < statusIDs.Length; i++)
     {
         statusIDsBuilder.Append(statusIDs[i]);
         if (i < statusIDs.Length - 1)
         {
             statusIDsBuilder.Append(",");
         }
     }
     requester.Params.Add(new ParamPair("ids", statusIDsBuilder.ToString()));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #13
0
 /// <summary>
 /// The async implementation of <see cref="ExistsFriendship"/>
 /// </summary>
 public static void ExistsFriendshipAsync(AsyncCallback<ExistsFriendshipResultInfo> callback, long userAID, long userBID)
 {
     var requester = new OAuthHttpGet(APIUri.ExistsFriendship);
     requester.Params.Add(new ParamPair("user_a", userAID.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("user_b", userBID.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #14
0
 /// <summary>
 /// The async implementation of <see cref="GetUnreadInfo"/>
 /// </summary>
 public static void GetUnreadInfoAsync(AsyncCallback<UnreadInfo> callback, bool withNewStatus = false, long? sinceID = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetUnreadInfo);
     if (withNewStatus)
         requester.Params.Add(new ParamPair("with_new_status", "1"));
     if(sinceID.HasValue)
         requester.Params.Add(new ParamPair("since_id", sinceID.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #15
0
 /// <summary>
 /// The async implementation of <see cref="GetHotUsers"/>
 /// </summary>
 public static void GetHotUsersAsync(AsyncCallback<Users> callback, string category = "")
 {
     var requester = new OAuthHttpGet(APIUri.GetHotUsers);
     if (!string.IsNullOrEmpty(category))
         requester.Params.Add(new ParamPair("category", category));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #16
0
 /// <summary>
 /// The async implementation of <see cref="GetUserInfo"/>
 /// </summary>
 public static void GetUserInfoAsync(AsyncCallback<UserInfo> callback, long userID)
 {
     var requester = new OAuthHttpGet(string.Format("{0}/{1}.xml",APIUri.GetUserInfo, userID));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #17
0
 /// <summary>
 /// The async implementation of <see cref="GetPrivacy"/>
 /// </summary>
 public static void GetPrivacyAsync(AsyncCallback<PrivacyInfo> callback)
 {
     var requester = new OAuthHttpGet(APIUri.GetPrivacy);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #18
0
 /// <summary>
 /// The async implementation of <see cref="GetUserSearchSuggestions"/>
 /// </summary>
 public static void GetUserSearchSuggestionsAsync(AsyncCallback<UserSuggestions> callback, string keyword, int type = 0, int? count = null, int? range = null)
 {
     ValidateArgument("keyword", keyword);
     var requester = new OAuthHttpGet(APIUri.GetUserSearchSuggestions);
     requester.Params.Add("q", RFC3986Encoder.UrlEncode(keyword));
     if (count.HasValue)
         requester.Params.Add("count", count.Value.ToString(InvariantCulture));
     requester.Params.Add("type", type.ToString(InvariantCulture));
     if (range.HasValue)
         requester.Params.Add("range", range.Value.ToString(InvariantCulture));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #19
0
 /// <summary>
 /// The async implementation of <see cref="GetSentDirectMessages"/>
 /// </summary>
 public static void GetSentDirectMessagesAsync(AsyncCallback<DirectMessages> callback, long? sinceID = null, long? maxID = null, int? page = null, int? count = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetSentDirectMessages);
     ConstructPagedRecordsParams(requester.Params, sinceID, maxID, page, count);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #20
0
 /// <summary>
 /// The async implementation of <see cref="GetWeekTrends"/>
 /// </summary>
 public static void GetWeekTrendsAsync(AsyncCallback<PeriodTrends> callback, bool basedOnCurrentApp = false)
 {
     var requester = new OAuthHttpGet(APIUri.GetWeekTrends);
     if (basedOnCurrentApp)
         requester.Params.Add("base_app", "1");
     else
         requester.Params.Add("base_app", "0");
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #21
0
 /// <summary>
 /// The async implementation of <see cref="GetStatus"/>
 /// </summary>
 public static void GetStatusAsync(AsyncCallback<StatusInfo> callback, long statusID)
 {
     ValidateArgument(statusID, "statusID");
     var requester = new OAuthHttpGet(string.Format("{0}/{1}.xml", APIUri.ShowStatus, statusID));
     requester.Params.Add(new ParamPair("id", statusID.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #22
0
 /// <summary>
 /// The async implementation of <see cref="GetBlockingListIDs"/>
 /// </summary>
 public static void GetBlockingListIDsAsync(AsyncCallback<UserIDs> callback, int? page = null, int? count = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetBlockingListIDs);
     if (count.HasValue)
         requester.Params.Add("page", count.Value.ToString(InvariantCulture));
     if (count.HasValue)
         requester.Params.Add("count", page.Value.ToString(InvariantCulture));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #23
0
 /// <summary>
 /// The async implementation of <see cref="GetSuggestedUsers"/>
 /// </summary>
 public static void GetSuggestedUsersAsync(AsyncCallback<Users> callback)
 {
     var requester = new OAuthHttpGet(APIUri.GetSuggestedUsers);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #24
0
        /// <summary>
        /// The async implementation of <see cref="GetRateLimitStatus"/>
        /// </summary>
        public static void GetRateLimitStatusAsync(AsyncCallback<RateLimitStatus> callback)
        {
            var requester = new OAuthHttpGet(APIUri.GetRateLimitStatus);
            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                var preprocess = new Func<string, string>(delegate(string response)
                {
                    return response.Replace("hash", "rate-limit-status").Replace(" type=\"integer\"", "").Replace(" type=\"datetime\"", "");
                });

                ProcessAsyncCallbackResponse(result, callback, preprocess);
            });
        }
예제 #25
0
 /// <summary>
 /// The async implementation of <see cref="GetTags"/>
 /// </summary>
 public static void GetTagsAsync(AsyncCallback<Tags> callback, long userID, int? page = null, int? count = null)
 {
     var requester = new OAuthHttpGet(APIUri.GetTags);
     requester.Params.Add("user_id", userID.ToString(InvariantCulture));
     if (page.HasValue)
         requester.Params.Add(new ParamPair("page", page.Value.ToString(InvariantCulture)));
     if (count.HasValue)
         requester.Params.Add(new ParamPair("count", count.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
예제 #26
0
        /// <summary>
        /// The async implementation of <see cref="GetUserTrends"/>
        /// </summary>
        public static void GetUserTrendsAsync(AsyncCallback<Trends> callback, long userID, int? page = null, int? count = null)
        {
            var requester = new OAuthHttpGet(APIUri.GetUserTrends);
            requester.Params.Add("user_id", userID.ToString(InvariantCulture));
            if (page.HasValue)
                requester.Params.Add("page", page.Value.ToString(InvariantCulture));
            if (count.HasValue)
                requester.Params.Add("count", count.Value.ToString(InvariantCulture));
            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                Func<string, string> preprocess = delegate(string response)
                {
                    response = response.Replace("trends", "userTrends").Replace("trend", "userTrend");

                    return response;
                };

                ProcessAsyncCallbackResponse(result, callback, preprocess);
            });
        }
예제 #27
0
 /// <summary>
 /// The async implementation of <see cref="VerifyCredential"/>
 /// </summary>
 public static void VerifyCredentialAsync(AsyncCallback<UserInfo> callback)
 {
     var requester = new OAuthHttpGet(APIUri.VerifyCredential);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }