/// <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); }
/// <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); }
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); }
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); }
/// <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); }
/// <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); }
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); }
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); }
/// <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); }
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); }
/// <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); }
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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
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); }
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); }
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); }
/// <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); }
/// <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); }
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); }
/// <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; } }
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); }
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); }
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); }