/// <summary> /// Updates the authenticating user's status, also known as tweeting. /// </summary> /// <param name="twitter"></param> /// <param name="accessToken"></param> /// <param name="status">The text of your status update, typically up to 140 characters. URL encode as necessary. t.co link wrapping may effect character counts.</param> /// <param name="includeEntities">When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities. /// </param> /// <returns></returns> public static JObject UpdateStatus(ConsumerBase twitter, string accessToken, String status, bool includeEntities) { var parts = new[] { MultipartPostPart.CreateFormPart("status", status), MultipartPostPart.CreateFormPart("include_entities", includeEntities.ToString()), }; HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateStatusEndpoint, accessToken, parts); IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request); using (var responseReader = response.GetResponseReader()) { var result = responseReader.ReadToEnd(); return(JObject.Parse(result)); } }
public static string Digg(ConsumerBase consumer, string accessToken, string id) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var extraData = new Dictionary <string, string>() { { "story_id", id } }; var request = consumer.PrepareAuthorizedRequest(DiggEndpoint, accessToken, extraData); var response = consumer.Channel.WebRequestHandler.GetResponse(request); string body = response.GetResponseReader().ReadToEnd(); return(body); }
/// <summary> /// Gets the Gmail address book's contents. /// </summary> /// <param name="consumer">The Google consumer.</param> /// <param name="accessToken">The access token previously retrieved.</param> /// <param name="maxResults">The maximum number of entries to return. If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number here.</param> /// <param name="startIndex">The 1-based index of the first result to be retrieved (for paging).</param> /// <returns>An XML document returned by Google.</returns> public static XDocument GetContacts(ConsumerBase consumer, string accessToken, int maxResults /* = 25*/, int startIndex /* = 1*/) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var extraData = new Dictionary <string, string>() { { "start-index", startIndex.ToString(CultureInfo.InvariantCulture) }, { "max-results", maxResults.ToString(CultureInfo.InvariantCulture) }, }; var request = consumer.PrepareAuthorizedRequest(GetContactsEndpoint, accessToken, extraData); var response = consumer.Channel.WebRequestHandler.GetResponse(request); string body = response.GetResponseReader().ReadToEnd(); XDocument result = XDocument.Parse(body); return(result); }
public static Stream GetDoc(ConsumerBase consumer, string accessToken, string docEndpoint, out long size) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var endpoint = new MessageReceivingEndpoint(docEndpoint, HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest); var extraData = new Dictionary <string, string>() /*{ {"GData-Version","3.0"} }*/; var request = consumer.PrepareAuthorizedRequest(endpoint, accessToken, extraData); var response = consumer.Channel.WebRequestHandler.GetResponse(request); if (!string.IsNullOrEmpty(response.Headers[HttpResponseHeader.ContentLength])) { long.TryParse(response.Headers[HttpResponseHeader.ContentLength], out size); } else { size = 0; } return(response.ResponseStream); }
public static XDocument GetDocList(ConsumerBase consumer, string accessToken, string nextEndpoint) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var endpoint = GetDocsEntriesEndpoint; if (!string.IsNullOrEmpty(nextEndpoint)) { endpoint = new MessageReceivingEndpoint(nextEndpoint, HttpDeliveryMethods.GetRequest); } var extraData = new Dictionary <string, string>() /*{ {"GData-Version","3.0"} }*/; var request = consumer.PrepareAuthorizedRequest(endpoint, accessToken, extraData); var response = consumer.Channel.WebRequestHandler.GetResponse(request); string body = response.GetResponseReader().ReadToEnd(); XDocument result = XDocument.Parse(body); return(result); }
/// <summary> /// Gets the Gmail address book's contents. /// </summary> /// <param name="consumer">The Google consumer.</param> /// <param name="accessToken">The access token previously retrieved.</param> /// <param name="maxResults">The maximum number of entries to return. If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number here.</param> /// <param name="startIndex">The 1-based index of the first result to be retrieved (for paging).</param> /// <returns>An XML document returned by Google.</returns> public static XDocument GetContacts(ConsumerBase consumer, string accessToken, int maxResults /* = 25*/, int startIndex /* = 1*/) { if (consumer == null) { throw new ArgumentNullException("consumer"); } var extraData = new Dictionary <string, string>() { { "start-index", startIndex.ToString(CultureInfo.InvariantCulture) }, { "max-results", maxResults.ToString(CultureInfo.InvariantCulture) }, }; var request = consumer.PrepareAuthorizedRequest(GetContactsEndpoint, accessToken, extraData); // Enable gzip compression. Google only compresses the response for recognized user agent headers. - Mike Lim request.AutomaticDecompression = DecompressionMethods.GZip; request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16"; var response = consumer.Channel.WebRequestHandler.GetResponse(request); string body = response.GetResponseReader().ReadToEnd(); XDocument result = XDocument.Parse(body); return(result); }