Пример #1
0
        /// <summary>
        /// Async OAuth Post
        /// </summary>
        /// <param name="url">Twitter Command</param>
        /// <param name="args">Command Arguments</param>
        /// <returns>HttpWebRequest for post</returns>
        public HttpWebRequest PostAsync(string url, Dictionary <string, string> args)
        {
            string paramsJoined =
                string.Join(
                    "&",
                    (from param in args
                     where !string.IsNullOrEmpty(param.Value)
                     select param.Key + "=" + OAuthTwitter.TwitterParameterUrlEncode(param.Value))
                    .ToArray());

            //url += "?" + paramsJoined;

            var req = WebRequest.Create(
                ProxyUrl + url +
                (string.IsNullOrEmpty(ProxyUrl) ? "?" : "&") +
                paramsJoined)
                      as HttpWebRequest;

            //req.ServicePoint.Expect100Continue = false;
            req.Method = HttpMethod.POST.ToString();

            req.Headers[HttpRequestHeader.Authorization] = OAuthTwitter.GetOAuthQueryStringForPost(url + "?" + paramsJoined);
            req.ContentLength = 0;

            InitializeRequest(req);

            return(req);
        }
Пример #2
0
        /// <summary>
        /// OAuth Post
        /// </summary>
        /// <param name="request">The request with the endpoint URL and the parameters to
        /// include in the POST entity.  Must not be null.</param>
        /// <param name="postData">Hash of parameters</param>
        /// <returns>request to send</returns>
        public virtual HttpWebRequest PostRequest(Request request, IDictionary <string, string> postData)
        {
            var auth = OAuthTwitter.GetOAuthQueryStringForPost(request, postData);

#if SILVERLIGHT
            var req = HttpWebRequest.Create(
                ProxyUrl + request.Endpoint +
                (string.IsNullOrEmpty(ProxyUrl) ? "?" : "&") +
                request.QueryString) as HttpWebRequest;
#else
            var req = WebRequest.Create(request.Endpoint) as HttpWebRequest;
#endif

            if (req != null)
            {
#if !SILVERLIGHT && !NETFX_CORE
                req.ServicePoint.Expect100Continue = false;
#endif
                req.Method = HttpMethod.POST.ToString();
                req.Headers[HttpRequestHeader.Authorization] = auth;
#if !WINDOWS_PHONE
                req.ContentType = "application/x-www-form-urlencoded";
#endif
#if !WINDOWS_PHONE && !NETFX_CORE
                req.ContentLength = 0;
#endif

                InitializeRequest(req);
            }

            return(req);
        }
Пример #3
0
        public HttpWebRequest Post(string url)
        {
            var req = WebRequest.Create(ProxyUrl + url) as HttpWebRequest;

            req.Method = HttpMethod.POST.ToString();

            req.Headers[HttpRequestHeader.Authorization] = OAuthTwitter.GetOAuthQueryStringForPost(url);

            InitializeRequest(req);

            return(req);
        }
Пример #4
0
        /// <summary>
        /// Async OAuth Post
        /// </summary>
        /// <param name="request">The request with the endpoint URL and the parameters to
        /// include in the POST entity.  Must not be null.</param>
        /// <param name="postData">Hash of parameters</param>
        /// <returns>HttpWebRequest for post</returns>
        public virtual HttpWebRequest PostAsync(Request request, IDictionary <string, string> postData)
        {
            var auth = OAuthTwitter.GetOAuthQueryStringForPost(request, postData);

            var req = WebRequest.Create(
                ProxyUrl + request.Endpoint +
                (string.IsNullOrEmpty(ProxyUrl) ? "?" : "&") +
                request.QueryString)
                      as HttpWebRequest;

            if (req != null)
            {
                req.Method = HttpMethod.POST.ToString();
                req.Headers[HttpRequestHeader.Authorization] = auth;
#if !WINDOWS_PHONE && !NETFX_CORE
                req.ContentLength = 0;
#endif

                InitializeRequest(req);
            }

            return(req);
        }