/// <summary> /// The async implementation of <see cref="ConvertToLongUrls"/> /// </summary> public static void ConvertToLongUrlsAsync(AsyncCallback<Urls> callback, params string[] shortUrls) { ValidateArgument(shortUrls, "shortUrls"); var count = shortUrls.Length; if (count == 0) throw new AMicroblogException(LocalErrorCode.ArgumentNotProvided, "Short urls not provided."); var requester = new HttpGet(APIUri.ConvertToLongUrls); requester.Params.Add(Constants.Source, Environment.AppKey); foreach (var longUrl in shortUrls) { requester.Params.Add("url_short", longUrl); } requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="GetShortUrlSharedCount"/> /// </summary> public static void GetShortUrlSharedCountAsync(AsyncCallback<Urls> callback, string shortUrl) { ValidateArgument(shortUrl, "shortUrl"); var requester = new HttpGet(APIUri.GetShortUrlSharedCount); requester.Params.Add(Constants.Source, Environment.AppKey); requester.Params.Add("url_short", shortUrl); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="SearchUsers"/> /// </summary> public static void SearchUsersAsync(AsyncCallback<Users> callback, string keyword, int? page = null, int? count = null, bool currentAppOnly = false) { ValidateArgument("keyword", keyword); var requester = new HttpGet(APIUri.SearchUsers); requester.Params.Add(Constants.Source, Environment.AppKey); requester.Params.Add("q", RFC3986Encoder.UrlEncode(keyword)); if (count.HasValue) requester.Params.Add("count", count.Value.ToString(InvariantCulture)); if (page.HasValue) requester.Params.Add("page", page.Value.ToString(InvariantCulture)); if (currentAppOnly) requester.Params.Add("base_app ", "1"); requester.RequestAsync(delegate(AsyncCallResult<string> result) { Func<string, string> preprocess = delegate(string response) { response = response.Replace("<searchResult>", string.Empty); response = response.Replace("</searchResult>", string.Empty); return response; }; ProcessAsyncCallbackResponse(result, callback, preprocess); }); }
/// <summary> /// The async implementation of <see cref="GetPublicStatuses"/> /// </summary> public static void GetPublicStatusesAsync(AsyncCallback<Statuses> callback, int count = 20, bool currentAppOnly = false) { var requester = new HttpGet(APIUri.PublicTimeline); requester.Params.Add(Constants.Source, Environment.AppKey); if (count != 20) requester.Params.Add(new ParamPair("count", count.ToString(InvariantCulture))); if (currentAppOnly) requester.Params.Add(new ParamPair("base_app", "1")); requester.RequestAsync(delegate(AsyncCallResult<string> result) { ProcessAsyncCallbackResponse(result, callback); }); }
/// <summary> /// The async implementation of <see cref="SearchStatuses"/> /// </summary> public static void SearchStatusesAsync(AsyncCallback<Statuses> callback, string keyword, int? statusType = null, bool? includePic = null, long? authorID = null, int? provice = null, int? city = null, long? startTime = null, long? endTime = null, int? page = null, int? count = null, bool returnCounter = false, bool currentAppOnly = false) { ValidateArgument(keyword, "keyword"); var requester = new HttpGet(APIUri.SearchStatuses); requester.Params.Add(Constants.Source, Environment.AppKey); requester.Params.Add("q", keyword); if (statusType.HasValue) requester.Params.Add("filter_ori", statusType.Value.ToString(InvariantCulture)); if (includePic.HasValue) requester.Params.Add("filter_pic", includePic.Value ? "1" : "2"); if (provice.HasValue) requester.Params.Add("provice", provice.Value.ToString(InvariantCulture)); if (city.HasValue) requester.Params.Add("city", city.Value.ToString(InvariantCulture)); if (startTime.HasValue) requester.Params.Add("starttime", startTime.Value.ToString(InvariantCulture)); if (endTime.HasValue) requester.Params.Add("endtime", endTime.Value.ToString(InvariantCulture)); if (page.HasValue) requester.Params.Add("page", page.Value.ToString(InvariantCulture)); if (count.HasValue) requester.Params.Add("count", count.Value.ToString(InvariantCulture)); if (returnCounter) requester.Params.Add("needcount", "true"); if (currentAppOnly) requester.Params.Add("base_app", "1"); requester.RequestAsync(delegate(AsyncCallResult<string> result) { Func<string, string> preprocess = delegate(string response) { response = response.Replace("<searchResult>", string.Empty); response = response.Replace("</searchResult>", string.Empty); return response; }; ProcessAsyncCallbackResponse(result, callback, preprocess); }); }