/// <summary>
 /// Makes a HTTP request based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="body">The body of the request.</param>
 /// <param name="options">The options to be used when serializing <paramref name="body"/>.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, XNode body, SaveOptions options)
 {
     if (body == null)
     {
         throw new ArgumentNullException(nameof(body));
     }
     return(DoHttpRequest(method, url, queryString, "text/xml", body.ToString(options)));
 }
 /// <summary>
 /// Makes a HTTP request based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="body">The body of the request.</param>
 /// <param name="formatting">The formatting to be used when serializing <paramref name="body"/>.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, JToken body, Formatting formatting)
 {
     if (body == null)
     {
         throw new ArgumentNullException(nameof(body));
     }
     return(DoHttpRequest(method, url, queryString, "application/json", body.ToString(formatting)));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates the string value used for making the signature.
 /// </summary>
 /// <param name="method">The method for the HTTP request.</param>
 /// <param name="url">The URL of the request.</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="body">The POST data.</param>
 /// <returns>The generated signature value.</returns>
 public virtual string GenerateSignatureValue(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData body)
 {
     return(String.Format(
                "{0}&{1}&{2}",
                method.ToString().ToUpper(),
                Uri.EscapeDataString(url.Split('#')[0].Split('?')[0]),
                Uri.EscapeDataString(GenerateParameterString(queryString, body))
                ));
 }
Ejemplo n.º 4
0
            /// <summary>
            /// Makes a HTTP request using the specified <paramref name="url"/> and <paramref name="method"/>.
            /// </summary>
            /// <param name="url">The URL of the request.</param>
            /// <param name="method">The HTTP method of the request.</param>
            /// <param name="queryString">The query string of the request.</param>
            /// <param name="postData">The POST data of the request.</param>
            /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the response.</returns>
            private static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData postData)
            {
                // Initialize the request
                SocialHttpRequest request = new SocialHttpRequest {
                    Url         = url,
                    Method      = method,
                    QueryString = queryString,
                    PostData    = postData
                };

                // Make the call to the URL
                return(request.GetResponse());
            }
Ejemplo n.º 5
0
 /// <summary>
 /// Generate the signature.
 /// </summary>
 /// <param name="method">The method for the HTTP request.</param>
 /// <param name="url">The URL of the request.</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="body">The POST data.</param>
 /// <returns>Returns the generated signature.</returns>
 public virtual string GenerateSignature(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData body) {
     HMACSHA1 hasher = new HMACSHA1(new ASCIIEncoding().GetBytes(GenerateSignatureKey()));
     return Convert.ToBase64String(hasher.ComputeHash(new ASCIIEncoding().GetBytes(GenerateSignatureValue(method, url, queryString, body))));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Generates the string value used for making the signature.
 /// </summary>
 /// <param name="method">The method for the HTTP request.</param>
 /// <param name="url">The URL of the request.</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="body">The POST data.</param>
 /// <returns>Returns the generated signature value.</returns>
 public virtual string GenerateSignatureValue(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData body) {
     return String.Format(
         "{0}&{1}&{2}",
         method.ToString().ToUpper(),
         Uri.EscapeDataString(url.Split('#')[0].Split('?')[0]),
         Uri.EscapeDataString(GenerateParameterString(queryString, body))
     );
 }
Ejemplo n.º 7
0
            /// <summary>
            /// Makes a HTTP request using the specified <code>url</code> and <code>method</code>.
            /// </summary>
            /// <param name="url">The URL of the request.</param>
            /// <param name="method">The HTTP method of the request.</param>
            /// <param name="queryString">The query string of the request.</param>
            /// <param name="postData">The POST data of the request.</param>
            /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the response.</returns>
            private static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData postData) {

                // Initialize the request
                SocialHttpRequest request = new SocialHttpRequest {
                    Url = url,
                    Method = method,
                    QueryString = queryString,
                    PostData = postData
                };

                // Make the call to the URL
                return request.GetResponse();

            }
Ejemplo n.º 8
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="postData">The POST data.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpPostData postData) {
     return DoHttpRequest(method, url, null, postData);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="options">The options for the call to the API.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpGetOptions options) {
     IHttpQueryString queryString = options == null ? null : options.GetQueryString();
     return DoHttpRequest(method, url, queryString);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url) {
     return DoHttpRequest(method, url, default(IHttpQueryString), default(IHttpPostData));
 }
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="contentType">The content type of the request - eg. <c>application/json</c>.</param>
 /// <param name="body">The body of the request.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, string contentType, string body)
 {
     return(DoHttpRequest(method, url, queryString == null ? null : new SocialHttpQueryString(queryString), contentType, body));
 }
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="postData">The POST data.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, NameValueCollection postData)
 {
     return(DoHttpRequest(method, url, queryString == null ? null : new SocialHttpQueryString(queryString), postData == null ? null : new SocialHttpPostData(postData)));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="postData">The POST data.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, NameValueCollection postData)
 {
     return(DoHttpRequest(method, url, new SocialHttpQueryString(queryString), new SocialHttpPostData(postData)));
 }
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString)
 {
     return(DoHttpRequest(method, url, queryString == null ? null : new SocialHttpQueryString(queryString), null));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url)
 {
     return(DoHttpRequest(method, url, default(IHttpQueryString), default(IHttpPostData)));
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Generates the signature.
        /// </summary>
        /// <param name="method">The method for the HTTP request.</param>
        /// <param name="url">The URL of the request.</param>
        /// <param name="queryString">The query string.</param>
        /// <param name="body">The POST data.</param>
        /// <returns>Returns the generated signature.</returns>
        public virtual string GenerateSignature(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData body)
        {
            HMACSHA1 hasher = new HMACSHA1(new ASCIIEncoding().GetBytes(GenerateSignatureKey()));

            return(Convert.ToBase64String(hasher.ComputeHash(new ASCIIEncoding().GetBytes(GenerateSignatureValue(method, url, queryString, body)))));
        }
Ejemplo n.º 17
0
            /// <summary>
            /// Makes a HTTP request to the underlying API based on the specified parameters.
            /// </summary>
            /// <param name="method">The HTTP method of the request.</param>
            /// <param name="url">The base URL of the request (no query string).</param>
            /// <param name="options">The options for the call to the API.</param>
            /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
            public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpGetOptions options)
            {
                IHttpQueryString queryString = options?.GetQueryString();

                return(DoHttpRequest(method, url, queryString));
            }
Ejemplo n.º 18
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <param name="postData">The POST data.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString, NameValueCollection postData) {
     return DoHttpRequest(method, url, new SocialHttpQueryString(queryString), new SocialHttpPostData(postData));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString)
 {
     return(DoHttpRequest(method, url, queryString, null));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString) {
     return DoHttpRequest(method, url, queryString, null);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="postData">The POST data.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpPostData postData)
 {
     return(DoHttpRequest(method, url, null, postData));
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Makes a HTTP request to the underlying API based on the specified parameters.
        /// </summary>
        /// <param name="method">The HTTP method of the request.</param>
        /// <param name="url">The base URL of the request (no query string).</param>
        /// <param name="queryString">The query string.</param>
        /// <param name="postData">The POST data.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
        public virtual SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, IHttpQueryString queryString, IHttpPostData postData) {

            // Some input validation
            if (String.IsNullOrWhiteSpace(url)) throw new ArgumentNullException("url");
            if (queryString == null) queryString = new SocialHttpQueryString();
            if (postData == null) postData = new SocialHttpPostData();

            // Initialize the request
            SocialHttpRequest request = new SocialHttpRequest {
                Method = method,
                Url = url,
                QueryString = queryString,
                PostData = postData
            };

            PrepareHttpRequest(request);

            // Make the call to the URL
            return request.GetResponse();

        }
Ejemplo n.º 23
0
 /// <summary>
 /// Makes a HTTP request to the underlying API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="queryString">The query string.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public static SocialHttpResponse DoHttpRequest(SocialHttpMethod method, string url, NameValueCollection queryString) {
     return DoHttpRequest(method, url, new SocialHttpQueryString(queryString), null);
 }