public static Tuple <List<Post>,ApiCallResponse> getGlobalStream(string access_token, Parameters parameter = null) { ApiCallResponse apiCallResponse = new ApiCallResponse(); List<Post> posts = new List<Post>(); try { if (string.IsNullOrEmpty(access_token)) { apiCallResponse.success = false; apiCallResponse.errorMessage = "Missing parameter access_token"; return new Tuple<List<Post>, ApiCallResponse>(posts, apiCallResponse); } string requestUrl = Common.baseUrl + "/stream/0/posts/stream/global"; if(parameter != null) { requestUrl = requestUrl + "?" + parameter.getQueryString(); } Dictionary<string, string> headers = new Dictionary<string, string>(); headers.Add("Authorization", "Bearer " + access_token); Helper.Response response = Helper.SendGetRequest(requestUrl, headers); return Helper.getData<List<Post>>(response); } catch (Exception exp) { apiCallResponse.success = false; apiCallResponse.errorMessage = exp.Message; apiCallResponse.errorDescription = exp.StackTrace; } return new Tuple<List<Post>, ApiCallResponse>(posts, apiCallResponse); }
public static Tuple<User,ApiCallResponse> unfollowByUsernameOrId(string access_token, string usernameOrId, Parameters parameter = null) { ApiCallResponse apiCallResponse = new ApiCallResponse(); User user = new User(); try { if (string.IsNullOrEmpty(access_token)) { apiCallResponse.success = false; apiCallResponse.errorMessage = "Missing parameter access_token"; return new Tuple<User, ApiCallResponse>(user, apiCallResponse); } if (string.IsNullOrEmpty(usernameOrId)) { apiCallResponse.success = false; apiCallResponse.errorMessage = "Missing parameter usernameOrId"; return new Tuple<User, ApiCallResponse>(user, apiCallResponse); } string requestUrl = Common.baseUrl + "/stream/0/users/" + Common.formatUserIdOrUsername(usernameOrId) + "/follow"; Dictionary<string, string> headers = new Dictionary<string, string>(); headers.Add("Authorization", "Bearer " + access_token); Helper.Response response = Helper.SendDeleteRequest(requestUrl, headers); return Helper.getData<User>(response); } catch (Exception exp) { apiCallResponse.success = false; apiCallResponse.errorMessage = exp.Message; apiCallResponse.errorDescription = exp.StackTrace; } return new Tuple<User, ApiCallResponse>(user, apiCallResponse); }
public static Tuple<List<Post>, ApiCallResponse> getMentionsOfUsernameOrId(string access_token, string usernameOrId, Parameters parameter = null) { ApiCallResponse apiCallResponse = new ApiCallResponse(); List<Post> emptyList = new List<Post>(); try { if (string.IsNullOrEmpty(access_token)) { apiCallResponse.success = false; apiCallResponse.errorMessage = "Missing parameter access_token"; return new Tuple<List<Post>, ApiCallResponse>(emptyList, apiCallResponse); } if (string.IsNullOrEmpty(usernameOrId)) { apiCallResponse.success = false; apiCallResponse.errorMessage = "Missing parameter username or id"; return new Tuple<List<Post>, ApiCallResponse>(emptyList, apiCallResponse); } string requestUrl = Common.baseUrl + "/stream/0/users/" + Common.formatUserIdOrUsername(usernameOrId) + "/mentions"; if(parameter != null) { requestUrl = requestUrl + "?" + parameter.getQueryString(); } Dictionary<string, string> headers = new Dictionary<string, string>(); headers.Add("Authorization", "Bearer " + access_token); Helper.Response response = Helper.SendGetRequest(requestUrl, headers); return Helper.getData<List<Post>>(response); } catch (Exception exp) { apiCallResponse.success = false; apiCallResponse.errorMessage = exp.Message; apiCallResponse.errorDescription = exp.StackTrace; } return new Tuple<List<Post>, ApiCallResponse>(emptyList, apiCallResponse); }