Ejemplo n.º 1
0
        public void TweetOnBehalfOf(string oauth_access_token, string oauth_token_secret, string postData)
        {
            HttpWebRequest request = PostTwits(oauth_consumer_key, oauth_consumer_secret, oauth_access_token, oauth_token_secret, postData);
            string         result  = OAuthHelper.getResponce(request);
            Dictionary <string, string> dcResult = OAuthUtility.GetQueryParameters(result);

            if (dcResult["status"] != "200")
            {
                this.oauth_error = result;
            }
        }
Ejemplo n.º 2
0
        public string GetRequestToken()
        {
            HttpWebRequest request = FetchRequestToken(httpMethod.POST, oauth_consumer_key, oauth_consumer_secret);
            string         result  = getResponce(request);
            Dictionary <string, string> resultData = OAuthUtility.GetQueryParameters(result);

            if (resultData.Keys.Contains("oauth_token"))
            {
                return(resultData["oauth_token"]);
            }
            else
            {
                this.oauth_error = result;
                return("");
            }
        }
Ejemplo n.º 3
0
        HttpWebRequest PostTwits(string oauth_consumer_key, string oauth_consumer_secret, string oauth_access_token, string oauth_token_secret, string postData)
        {
            postData = "trim_user=true&include_entities=true&status=" + postData;
            string updateStatusURL = "https://api.twitter.com/1/statuses/update.json?" + postData;

            string outUrl;
            string OAuthHeaderPOST = OAuthUtility.GetAuthorizationHeaderForPost_OR_QueryParameterForGET(new Uri(updateStatusURL), callbackUrl, httpMethod.POST.ToString(), oauth_consumer_key, oauth_consumer_secret, oauth_access_token, oauth_token_secret, out outUrl);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(outUrl);

            request.Method = httpMethod.POST.ToString();
            request.Headers["Authorization"] = OAuthHeaderPOST;

            byte[] array = Encoding.ASCII.GetBytes(postData);
            request.GetRequestStream().Write(array, 0, array.Length);
            return(request);
        }
Ejemplo n.º 4
0
        public void GetUserTwAccessToken(string oauth_token, string oauth_verifier)
        {
            HttpWebRequest request = FetchAccessToken(httpMethod.POST, oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_verifier);
            string         result  = getResponce(request);

            Dictionary <string, string> resultData = OAuthUtility.GetQueryParameters(result);

            if (resultData.Keys.Contains("oauth_token"))
            {
                this.oauth_access_token        = resultData["oauth_token"];
                this.oauth_access_token_secret = resultData["oauth_token_secret"];
                this.user_id     = resultData["user_id"];
                this.screen_name = resultData["screen_name"];
            }
            else
            {
                this.oauth_error = result;
            }
        }
Ejemplo n.º 5
0
        HttpWebRequest FetchRequestToken(httpMethod method, string oauth_consumer_key, string oauth_consumer_secret)
        {
            string OutUrl      = "";
            string OAuthHeader = OAuthUtility.GetAuthorizationHeaderForPost_OR_QueryParameterForGET(new Uri(REQUEST_TOKEN), callbackUrl, method.ToString(), oauth_consumer_key, oauth_consumer_secret, "", "", out OutUrl);

            if (method == httpMethod.GET)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(OutUrl + "?" + OAuthHeader);
                request.Method = method.ToString();
                return(request);
            }
            else if (method == httpMethod.POST)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(OutUrl);
                request.Method = method.ToString();
                request.Headers["Authorization"] = OAuthHeader;
                return(request);
            }
            else
            {
                return(null);
            }
        }