Esempio n. 1
0
 /// <summary>
 /// The async implementation of <see cref="AddToFavorite"/>
 /// </summary>
 public static void AddToFavoriteAsync(AsyncCallback<StatusInfo> callback, long statusID)
 {
     var requester = new OAuthHttpPost(APIUri.AddToFavorite);
     requester.Params.Add("id", statusID.ToString(InvariantCulture));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 2
0
 /// <summary>
 /// The async implementation of <see cref="Block"/>
 /// </summary>
 public static void BlockAsync(AsyncCallback<UserInfo> callback, long? userID = null, string screenName = null)
 {
     var requester = new OAuthHttpPost(APIUri.Block);
     if (userID.HasValue)
         requester.Params.Add("user_id", userID.Value.ToString(InvariantCulture));
     if (!string.IsNullOrEmpty(screenName))
         requester.Params.Add("screen_name", RFC3986Encoder.UrlEncode(screenName));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 3
0
 /// <summary>
 /// The async implementation of <see cref="Comment"/>
 /// </summary>
 public static void CommentAsync(AsyncCallback<CommentInfo> callback, long statusID, string comment, bool commentToOriginalAuthor = false)
 {
     ValidateArgument(statusID, "statusID");
     ValidateArgument(comment, "comment");
     var requester = new OAuthHttpPost(APIUri.Comment);
     requester.Params.Add(new ParamPair("id", statusID.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("comment", RFC3986Encoder.UrlEncode(comment)));
     if (commentToOriginalAuthor)
         requester.Params.Add(new ParamPair("comment_ori", "1"));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 4
0
        /// <summary>
        /// The async implementation of <see cref="FollowTrend"/>
        /// </summary>
        public static void FollowTrendAsync(AsyncCallback<long> callback, string trendName)
        {
            ValidateArgument(trendName, "trendName");
            var requester = new OAuthHttpPost(APIUri.FollowTrend);
            requester.Params.Add("trend_name", trendName);
            requester.RequestAsync(delegate(AsyncCallResult<string> result)
            {
                Func<string, long> customProcess = delegate(string response)
                    {
                        var match = Regex.Match(response, @"<topicid>(\d+?)</topicid>", RegexOptions.IgnoreCase);

                        var topicID = long.Parse(match.Groups[1].Value);

                        return topicID;
                    };

                ProcessAsyncCallbackResponseCustom(result, callback, customProcess);
            });
        }
Esempio n. 5
0
 /// <summary>
 /// The async implementation of <see cref="SendDirectMessage"/>
 /// </summary>
 public static void SendDirectMessageAsync(AsyncCallback<DirectMessageInfo> callback, string receiverScreenName, string message)
 {
     ValidateArgument(receiverScreenName, "receiverScreenName");
     ValidateArgument(message, "message");
     var requester = new OAuthHttpPost(APIUri.SendDirectMessage);
     requester.Params.Add("screen_name", RFC3986Encoder.UrlEncode(receiverScreenName));
     requester.Params.Add("text", RFC3986Encoder.UrlEncode(message));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 6
0
 /// <summary>
 /// The async implementation of <see cref="SendDirectMessage"/>
 /// </summary>
 public static void SendDirectMessageAsync(AsyncCallback<DirectMessageInfo> callback, long receiverID, string message)
 {
     ValidateArgument(message, "message");
     var requester = new OAuthHttpPost(APIUri.SendDirectMessage);
     requester.Params.Add("user_id", receiverID.ToString(InvariantCulture));
     requester.Params.Add("text", RFC3986Encoder.UrlEncode(message));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 7
0
 /// <summary>
 /// The async implementation of <see cref="ReplyComment"/>
 /// </summary>
 public static void ReplyCommentAsync(AsyncCallback<CommentInfo> callback, long commentID, string comment, long statusID, bool withoutMention = false)
 {
     ValidateArgument(commentID, "commentID");
     ValidateArgument(comment, "comment");
     var requester = new OAuthHttpPost(APIUri.ReplyComment);
     requester.Params.Add(new ParamPair("cid", commentID.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("comment", RFC3986Encoder.UrlEncode(comment)));
     requester.Params.Add(new ParamPair("id", statusID.ToString(InvariantCulture)));
     if (withoutMention)
         requester.Params.Add(new ParamPair("without_mention", "1"));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 8
0
 /// <summary>
 /// The async implementation of <see cref="PostStatus"/>
 /// </summary>
 public static void PostStatusAsync(AsyncCallback<StatusInfo> callback, UpdateStatusInfo updateStatusInfo)
 {
     // Validates arguments
     ValidateArgument(updateStatusInfo, "updateStatusInfo");
     ValidateArgument(updateStatusInfo.Status, "updateStatusInfo.Status");
     Collection<ParamPair> customParams = new Collection<ParamPair>();
     customParams.Add(new ParamPair("status", RFC3986Encoder.UrlEncode(updateStatusInfo.Status)));
     if (updateStatusInfo.ReplyTo.HasValue)
     {
         customParams.Add(new ParamPair("in_reply_to_status_id", updateStatusInfo.ReplyTo.Value.ToString()));
     }
     if (updateStatusInfo.Latitude.HasValue && updateStatusInfo.Longitude.HasValue)
     {
         customParams.Add(new ParamPair("lat", updateStatusInfo.Latitude.Value.ToString(InvariantCulture)));
         customParams.Add(new ParamPair("long", updateStatusInfo.Longitude.Value.ToString(InvariantCulture)));
     }
     // The status text must be url-encoded.
     var requester = new OAuthHttpPost(APIUri.UpdateStatus, customParams);
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 9
0
 /// <summary>
 /// The async implementation of <see cref="Forward"/>
 /// </summary>
 public static void ForwardAsync(AsyncCallback<StatusInfo> callback, long statusID, string repostStatusText, bool commentToAuthor = false, bool commentToOriginalAuthor = false)
 {
     ValidateArgument(statusID, "statusID");
     var requester = new OAuthHttpPost(APIUri.RepostStatus);
     requester.Params.Add(new ParamPair("id", statusID.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("status", RFC3986Encoder.UrlEncode(repostStatusText)));
     var isComment = 0;
     if (commentToAuthor)
         isComment++;
     if (commentToOriginalAuthor)
         isComment++;
     requester.Params.Add(new ParamPair("is_comment", isComment.ToString()));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 10
0
 /// <summary>
 /// The async implementation of <see cref="Follow"/>
 /// </summary>
 public static void FollowAsync(AsyncCallback<UserInfo> callback, long? targetUserID = null, string targetUserScreenName = null)
 {
     var requester = new OAuthHttpPost(APIUri.CreateFriendship);
     if(targetUserID.HasValue)
         requester.Params.Add(new ParamPair("user_id", targetUserID.Value.ToString(InvariantCulture)));
     if (!string.IsNullOrEmpty(targetUserScreenName))
         requester.Params.Add(new ParamPair("screen_name", targetUserScreenName));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 11
0
 /// <summary>
 /// The async implementation of <see cref="DeleteComments"/>
 /// </summary>
 public static void DeleteCommentsAsync(AsyncCallback<Comments> callback, long[] commentIDs)
 {
     ValidateArgument(commentIDs, "commentIDs");
     StringBuilder cidBuilder = new StringBuilder();
     foreach (var item in commentIDs)
     {
         cidBuilder.Append(item);
         cidBuilder.Append(",");
     }
     var requester = new OAuthHttpPost(APIUri.DeleteComments);
     requester.Params.Add(new ParamPair("ids", cidBuilder.ToString()));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 12
0
 /// <summary>
 /// The async implementation of <see cref="CreateTags"/>
 /// </summary>
 public static void CreateTagsAsync(AsyncCallback<TagIDs> callback, params string[] tags)
 {
     ValidateArgument(tags, "tags");
     var count = tags.Length;
     if (count == 0)
         throw new AMicroblogException(LocalErrorCode.ArgumentNotProvided, "Tags not provided.");
     var tagBuilder = new StringBuilder();
     for (int i = 0; i < tags.Length; i++)
     {
         tagBuilder.Append(tags[i]);
         if( i < count -1)
             tagBuilder.Append(",");
     }
     var requester = new OAuthHttpPost(APIUri.CreateTags);
     requester.Params.Add("tags", tagBuilder.ToString());
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 13
0
 /// <summary>
 /// The async implementation of <see cref="UpdateProfile"/>
 /// </summary>
 public static void UpdateProfileAsync(AsyncCallback<UserInfo> callback, UpdateProfileInfo updateProfileInfo)
 {
     ValidateArgument(updateProfileInfo, "updateProfileInfo");
     var requester = new OAuthHttpPost(APIUri.UpdateProfileImage);
     if(!string.IsNullOrEmpty(updateProfileInfo.ScreenName))
         requester.Params.Add("name", updateProfileInfo.ScreenName);
     if (!string.IsNullOrEmpty(updateProfileInfo.Gender))
         requester.Params.Add("gender", updateProfileInfo.Gender);
     if (!string.IsNullOrEmpty(updateProfileInfo.Description))
         requester.Params.Add("description", updateProfileInfo.Description);
     if (updateProfileInfo.Province.HasValue)
         requester.Params.Add("province", updateProfileInfo.Province.Value.ToString(InvariantCulture));
     if (updateProfileInfo.City.HasValue)
         requester.Params.Add("city", updateProfileInfo.City.Value.ToString(InvariantCulture));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }
Esempio n. 14
0
 /// <summary>
 /// The async implementation of <see cref="UpdatePrivacy"/>
 /// </summary>
 public static void UpdatePrivacyAsync(VoidAsyncCallback callback, int? commentPrivacy = null, int? messagePrivacy = null, int? realNamePrivacy = null, int? geoPrivacy = null, int? badgePrivacy = null)
 {
     var requester = new OAuthHttpPost(APIUri.UpdatePrivacy);
     if (commentPrivacy.HasValue)
         requester.Params.Add(new ParamPair("comment", commentPrivacy.Value.ToString(InvariantCulture)));
     if (messagePrivacy.HasValue)
         requester.Params.Add(new ParamPair("message", messagePrivacy.Value.ToString(InvariantCulture)));
     if (realNamePrivacy.HasValue)
         requester.Params.Add(new ParamPair("realname", realNamePrivacy.Value.ToString(InvariantCulture)));
     if (geoPrivacy.HasValue)
         requester.Params.Add(new ParamPair("geo", geoPrivacy.Value.ToString(InvariantCulture)));
     if (badgePrivacy.HasValue)
         requester.Params.Add(new ParamPair("badge", badgePrivacy.Value.ToString(InvariantCulture)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackVoidResponse(result, callback);
     });
 }
Esempio n. 15
0
 /// <summary>
 /// The async implementation of <see cref="UpdateFriendRemark"/>
 /// </summary>
 public static void UpdateFriendRemarkAsync(AsyncCallback<Users> callback, long friendUserID, string remark)
 {
     var requester = new OAuthHttpPost(APIUri.UpdateRemark);
     requester.Params.Add(new ParamPair("user_id", friendUserID.ToString(InvariantCulture)));
     requester.Params.Add(new ParamPair("remark", RFC3986Encoder.UrlEncode(remark)));
     requester.RequestAsync(delegate(AsyncCallResult<string> result)
     {
         ProcessAsyncCallbackResponse(result, callback);
     });
 }