예제 #1
0
 /// <summary>
 /// 取消收藏指定消息(当前用户的收藏)
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="id"></param>
 /// <param name="mode"></param>
 public void DestroyFavorite(Action<Status> callback, string id, string mode = null)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     DestroyFavoriteCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     PostData("http://api.fanfou.com/statuses/favorites/destroy/id.json", parameters, DestroyFavoriteEnd);
 }
예제 #2
0
파일: Blocks.cs 프로젝트: chwzou/WP7Fanfou
 /// <summary>
 /// 获取黑名单上用户资料
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="mode"></param>
 /// <param name="page"></param>
 /// <param name="count">count不设置的时候默认值为20</param>
 public void GetBlocking(Action<ICollection<User>> callback, string mode = null, int? page = null, int? count = null)
 {
     this.GetBlockingCallBack = callback;
     var parameters = new Parameters();
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (page != null) parameters.Add("page", page);
     if (count != null) parameters.Add("count", count);
     GetData("http://api.fanfou.com/blocks/blocking.json", parameters, GetBlockingEnd);
 }
예제 #3
0
파일: Users.cs 프로젝트: chwzou/WP7Fanfou
 public void UsersShow(Action<User> callback, string id = null ,string mode = null, string format = null)
 {
     // if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     UsersShowCallBack = callback;
     var parameters = new Parameters();
     if (!string.IsNullOrEmpty(id)) parameters.Add("id", id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     GetData("http://api.fanfou.com/users/show.json", parameters, UsersShowEnd);
 }
예제 #4
0
        public void CreateFavorite(Action<Status> callback, string id, string mode = null, string format = null)
        {
            if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
            CreateFavoriteCallBack = callback;
            var parameters = new Parameters();

            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            PostData(string.Format("http://api.fanfou.com/statuses/favorites/create/{0}.json", id), parameters, CreateFavoriteEnd);
        }
예제 #5
0
        /// <summary>
        /// 添加用户为好友
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="id"></param>
        /// <param name="mode"></param>
        public void CreateFriendship(Action<User> callback, string id, string mode = null)
        {
            if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
            CreateFriendshipCallBack = callback;
            var parameters = new Parameters();
            parameters.Add("id", id);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);

            PostData("http://api.fanfou.com/friendships/create.json", parameters, CreateFriendshipEnd);
        }
예제 #6
0
        /// <summary>
        /// 返回用户关注者的id列表
        /// </summary>
        /// <param name="callback"></param>
        public void GetFollowersIds(Action<ICollection<string>> callback, string id = null, int? page = null, int? count = null)
        {

            FollowersIdsCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(id)) parameters.Add("id", id);
            if (page != null) parameters.Add("page", page);
            if (count != null) parameters.Add("count", count);
            GetData("http://api.fanfou.com/followers/ids.json", parameters, FollowersIdsEnd);
        }
예제 #7
0
        public void GetFavorites(Action<ICollection<Status>> callback, string id = null, int? count = null, int? page = null, string mode = null, string format = null)
        {

            GetFavoritesCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(id)) parameters.Add("id", id);
            if (count != null) parameters.Add("count", count);
            if (page != null) parameters.Add("page", page);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            GetData("http://api.fanfou.com/favorites/id.json", parameters, GetFavoritesEnd);
        }
예제 #8
0
파일: Users.cs 프로젝트: chwzou/WP7Fanfou
 public void GetUsersByTagged(Action<ICollection<User>> callback, string tag, int count = 100, int? page = null, string mode = null, string format = null)
 {
     if (string.IsNullOrEmpty(tag)) throw new ArgumentException("tag不能为空");
     this.GetUsersByTaggedCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("tag", tag);
     parameters.Add("count", count);
     if (page != null) parameters.Add("page", page);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     GetData("", parameters, GetUsersByTaggedEnd);
 }
예제 #9
0
파일: Blocks.cs 프로젝트: chwzou/WP7Fanfou
        /// <summary>
        /// 把指定id用户加入黑名单
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="id"></param>
        /// <param name="mode"></param>
        /// <param name="format"></param>
        public void CreateBlock(Action<User> callback, string id, string mode = null, string format = null)
        {
            if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
            this.CreateBlockCallBack = callback;
            var parameters = new Parameters();
            parameters.Add("id", id);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);

            GetData("http://api.fanfou.com/blocks/create.json", parameters, CreateBlockEnd);


        }
예제 #10
0
파일: Photos.cs 프로젝트: chwzou/WP7Fanfou
 public void Upload(Action<Status> callback, UploadFile image, string status, string source = null,
                    string location = null, string mode = null, string format = null)
 {
     if (string.IsNullOrEmpty(status)) throw new ArgumentException("status不能为空");
     UpdateStatusCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("status", status);
     if (!string.IsNullOrEmpty(source)) parameters.Add("source", source);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     if (!string.IsNullOrEmpty(location)) parameters.Add("location", location);
     var file = new Files();
     file.Add("photo", image);
     PostData("http://api.fanfou.com/photos/upload.json", parameters, file, UpdateStatusEnd);
 }
예제 #11
0
파일: OAuth.cs 프로젝트: chwzou/WP7Fanfou
 /// <summary>
 /// 获取未授权的Request Token. 
 /// 如果获取成功, 对象实例的Token与TokenSecret属性值将改为request_token与request_secret
 /// </summary>
 /// <param name="requestUrl">API请求地址</param>
 /// <param name="callback">返回函数</param>
 /// <returns>是否获取request token成功</returns>
 public void GetRequestToken(string requestUrl, Action<string> callback)
 {
     this.Token = string.Empty;
     this.TokenSecret = string.Empty;
     var parameters = new Parameters();
     parameters.Add("oauth_callback", "null");
     this.GetOAuthToken(requestUrl, parameters, EndRequestToken, callback);
 }
예제 #12
0
파일: Users.cs 프로젝트: chwzou/WP7Fanfou
        public void GetUsersTagList(Action<ICollection<string>> callback, string id = null)
        {

            GetUsersTagListCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(id)) parameters.Add("id", id);
            GetData("http://api.fanfou.com/users/tag_list.json", parameters, GetUsersTagListEnd);
        }
예제 #13
0
 /// <summary>
 /// 返回搜索关键字的详细信息
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="id"></param>
 public void SavedSearchesShow(Action<SavedSearch> callback, string id)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     SavedSearchesShowCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     GetData("http://api.fanfou.com/saved_searches/show.json", parameters, SavedSearchesShowEnd);
 }
예제 #14
0
 /// <summary>
 /// 删除某条私信
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="id"></param>
 public void DestroyMessage(Action<DirectMessageObj> callback, string id)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     DestroyMessageCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     GetData("http://api.fanfou.com/direct_messages/destroy.json", parameters, DestroyMessageEnd);
 }
예제 #15
0
        /// <summary>
        /// 显示指定用户及其好友的消息(未设置隐私用户和登录用户好友的消息)
        /// </summary>
        /// <param name="callback"></param>
        public void GetHomeTimeLine(Action<ICollection<Status>> callback, string id = null, string since_id = null, string max_id = null, int? count = null, int? page = null, string mode = null, string format = null)
        {

            GetHomeTimeLineCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(id)) parameters.Add("id", id);
            if (!string.IsNullOrEmpty(since_id)) parameters.Add("since_id", since_id);
            if (!string.IsNullOrEmpty(max_id)) parameters.Add("max_id", max_id);
            if (count != null) parameters.Add("count", count);
            if (page != null) parameters.Add("page", page);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            GetData("http://api.fanfou.com/statuses/home_timeline.json", parameters, GetHomeTimeLineEnd);
        }
예제 #16
0
 /// <summary>
 /// 以对话的形式返回当前用户与某用户的私信
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="id"></param>
 /// <param name="count"></param>
 /// <param name="page"></param>
 /// <param name="max_id"></param>
 /// <param name="since_id"></param>
 /// <param name="format"></param>
 /// <param name="mode"></param>
 public void GetConversation(Action<ICollection<DirectMessageObj>> callback, string id, int? count = null,
                             int? page = null, string max_id = null, string since_id = null, string format = null,
                             string mode = null)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     GetConversationCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     if (!string.IsNullOrEmpty(since_id)) parameters.Add("since_id", since_id);
     if (!string.IsNullOrEmpty(max_id)) parameters.Add("max_id", max_id);
     if (count != null) parameters.Add("count", count);
     if (page != null) parameters.Add("page", page);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     GetData("http://api.fanfou.com/direct_messages/conversation.json", parameters, GetConversationEnd);
 }
예제 #17
0
파일: Account.cs 프로젝트: chwzou/WP7Fanfou
        /// <summary>
        /// 通过 API 更新用户资料
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="url"></param>
        /// <param name="mode"></param>
        /// <param name="location"></param>
        /// <param name="description"></param>
        /// <param name="name"></param>
        /// <param name="email"></param>
        public void UpdateProfile(Action<User> callback, string url = null, string mode = null, string location = null, string description = null, string name = null, string email = null)
        {

            UpdateProfileCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(url)) parameters.Add("url", url);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(location)) parameters.Add("location", location);
            if (!string.IsNullOrEmpty(description)) parameters.Add("description", description);
            if (!string.IsNullOrEmpty(name)) parameters.Add("name", name);
            if (!string.IsNullOrEmpty(email)) parameters.Add("email", email);
            GetData("http://api.fanfou.com/account/update_profile.json", parameters, UpdateProfileEnd);
        }
예제 #18
0
파일: Search.cs 프로젝트: chwzou/WP7Fanfou
        /// <summary>
        /// 
        /// </summary>
        /// <param name="queryWord"></param>
        /// <param name="callback"></param>
        /// <param name="sinceId"></param>
        /// <param name="maxId"></param>
        /// <param name="count"></param>
        /// <param name="mode"></param>
        /// <param name="format"></param>
        public void SearchPublicTime(Action<ICollection<Status>> callback, string queryWord, string sinceId = null, string maxId = null, int? count = null, string mode = null, string format = null)
        {

            if (String.IsNullOrEmpty(queryWord))
                throw new ArgumentException("搜索关键字不能为空");

            this.SearchPublicTimeCallBack = callback;
            var paramters = new Parameters();
            paramters.Add("q", queryWord);
            if (!string.IsNullOrEmpty(sinceId)) paramters.Add("since_id", sinceId);
            if (!string.IsNullOrEmpty(maxId)) paramters.Add("max_id", maxId);
            if (count != null) paramters.Add("count", count);
            if (!string.IsNullOrEmpty(mode)) paramters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) paramters.Add("format", format);
            GetData("http://api.fanfou.com/search/public_timeline.json", paramters, SearchPublicTimeEnd);
        }
예제 #19
0
        /// <summary>
        /// 查询Follow请求.
        /// </summary>
        /// <param name="callback"></param>
        public void RequestFriendship(Action<ICollection<User>> callback, int? page = null, int? count = null, string mode = null, string format = null)
        {

            RequestFriendshipCallBack = callback;
            var parameters = new Parameters();
            if (page != null) parameters.Add("page", page);
            if (count != null) parameters.Add("count", count);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            GetData("http://api.fanfou.com/friendships/requests.json", parameters, RequestFriendshipEnd);
        }
예제 #20
0
 /// <summary>
 /// 增加OAuth授权的参数
 /// </summary>
 /// <param name="requestMethod">请求方法.如GET或POST</param>
 /// <param name="requestUrl">API请求地址</param>
 /// <param name="parameters">提交参数</param>
 /// <returns></returns>
 protected virtual void AddOAuthParameter(string requestMethod, string requestUrl, Parameters parameters)
 {
     parameters.Add("oauth_consumer_key", this.OAuth.AppKey);
     parameters.Add("oauth_token", this.OAuth.Token);
     parameters.Add("oauth_signature_method", "HMAC-SHA1");
     parameters.Add("oauth_timestamp", Util.GenerateTimestamp().ToString());
     parameters.Add("oauth_nonce", Util.GenerateRndNonce());
     parameters.Add("oauth_version", "1.0");
     parameters.Add("oauth_signature", this.OAuth.GenerateSignature(requestMethod, requestUrl, parameters));
 }
예제 #21
0
        public void GetInboxMessageses(Action<ICollection<DirectMessageObj>> callback, int? count = null,
                                    int? page = null, string max_id = null, string since_id = null, string format = null,
                                    string mode = null)
        {

            GetInboxMessagesesCallBack = callback;
            var parameters = new Parameters();
            if (!string.IsNullOrEmpty(since_id)) parameters.Add("since_id", since_id);
            if (!string.IsNullOrEmpty(max_id)) parameters.Add("max_id", max_id);
            if (count != null) parameters.Add("count", count);
            if (page != null) parameters.Add("page", page);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            GetData("http://api.fanfou.com/direct_messages/inbox.json", parameters, GetInboxMessagesesEnd);
        }
예제 #22
0
        public void GetConversationList(Action<ConversationList> callback, int? page = null, int? count = null,
                                        string mode = null)
        {

            GetConversationListCallBack = callback;
            var parameters = new Parameters();
            if (page != null) parameters.Add("page", page);
            if (count != null) parameters.Add("count", count);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            GetData("http://api.fanfou.com/direct_messages/conversation_list.json", parameters, GetConversationListEnd);
        }
예제 #23
0
파일: Users.cs 프로젝트: chwzou/WP7Fanfou
 public void CancleRecommendation(Action<User> callback, string id, string mode = null, string format = null)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     CancleRecommendationCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     GetData("http://api.fanfou.com/2/users/cancel_recommendation.json", parameters, CancleRecommendationEnd);
 }
예제 #24
0
파일: Search.cs 프로젝트: chwzou/WP7Fanfou
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="q"></param>
        /// <param name="count"></param>
        /// <param name="page"></param>
        /// <param name="mode"></param>
        /// <param name="format"></param>
        public void SearchUsers(Action<SearchUsers> callback, string q, int? count = null, int? page = null, string mode = null, string format = null)
        {
            if (string.IsNullOrEmpty(q))
            {
                throw new ArgumentException("搜索关键字不能为空");

            }
            this.SearchUsersCallBack = callback;
            var paramters = new Parameters();
            paramters.Add("q", q);
            if (count != null) paramters.Add("count", count);
            if (page != null) paramters.Add("page", page);
            if (!string.IsNullOrEmpty(mode)) paramters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) paramters.Add("format", format);
            GetData("http://api.fanfou.com/search/users.json", paramters, SearchUserEnd);

        }
예제 #25
0
파일: OAuth.cs 프로젝트: chwzou/WP7Fanfou
 /// <summary>
 /// 同步获取授权的Access Token,调用此方法时必须设置Token与TokenSecret属性的值为request_token与request_secret
 /// 如果获取成功, 对象实例的Token与TokenSecret属性值将改为access_token与access_secret
 /// </summary>
 /// <param name="requestUrl">API请求地址</param>
 /// <param name="verifier">请求授权request token时返回的验证码</param> 
 /// <param name="callback">回调,参数是微博帐户名</param>
 /// <returns>是否获取Access Token成功</returns>
 public void GetAccessToken(string requestUrl, string verifier, Action<string> callback)
 {
     var parameters = new Parameters();
     parameters.Add("oauth_token", this.Token);
     parameters.Add("oauth_verifier", verifier);
     this.GetOAuthToken(requestUrl, parameters, EndAccessToken, callback);
 }
예제 #26
0
파일: Blocks.cs 프로젝트: chwzou/WP7Fanfou
 public void DestroyBlock(Action<User> callback, string id, string mode = null)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     DestroyBlockCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     GetData("http://api.fanfou.com/blocks/destroy.json", parameters, DestroyBlockEnd);
 }
예제 #27
0
파일: OAuth.cs 프로젝트: chwzou/WP7Fanfou
        /// <summary>
        /// 获取授权Token
        /// </summary>
        /// <param name="requestUrl">API请求地址</param>
        /// <param name="parameters"></param>
        /// <param name="responseEnd"></param>
        /// <returns></returns>
        private void GetOAuthToken(string requestUrl, Parameters parameters, Action<string, Action<string>> responseEnd, Action<string> callback)
        {
            this.LastError = null;
            parameters.Add("oauth_consumer_key", this.AppKey);
            parameters.Add("oauth_signature_method", "HMAC-SHA1");
            parameters.Add("oauth_timestamp", Util.GenerateTimestamp());
            parameters.Add("oauth_nonce", Util.GenerateRndNonce());
            parameters.Add("oauth_version", "1.0");
            parameters.Add("oauth_signature", this.GenerateSignature("GET", requestUrl, parameters));
            string url = string.Concat(requestUrl, "?", parameters.BuildQueryString(true));

            var request = new AsyncHttpRequest(url, this.Charset);
            try
            {
                request.Get(responseEnd, callback);
            }
            catch (Exception ex)
            {
                this.LastError = ex;
            }
        }
예제 #28
0
 public void NewDirectMessage(Action<DirectMessageObj> callback, string user, string text, string in_reply_to_id = null, string mode = null)
 {
     if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(text)) throw new ArgumentException("user不能为空");
     NewDirectMessageCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("user", user);
     parameters.Add("text", text);
     if (!string.IsNullOrEmpty(in_reply_to_id)) parameters.Add("in_reply_to_id", in_reply_to_id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     PostData("http://api.fanfou.com/direct_messages/new.json", parameters, NewDirectMessageEnd);
 }
예제 #29
0
 public void ShowStatus(Action<Status> callback, string id, string mode = null, string format = null)
 {
     if (string.IsNullOrEmpty(id)) throw new ArgumentException("id不能为空");
     ShowStatusCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("id", id);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     GetData("http://api.fanfou.com/statuses/show.json", parameters, ShowStatusEnd);
 }
예제 #30
0
파일: Users.cs 프로젝트: chwzou/WP7Fanfou
        public void GetUserRecommendation(Action<ICollection<User>> callback, int? count = null, int? page = null, string mode = null, string format = null)
        {

            GetUserRecommendationCallBack = callback;
            var parameters = new Parameters();
            if (count != null) parameters.Add("count", count);
            if (page != null) parameters.Add("page", page);
            if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
            if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
            GetData("http://api.fanfou.com/2/users/recommendation.json", parameters, GetUserRecommendationEnd);
        }