Esempio n. 1
0
        static HttpWebRequest GetTimelineRequest(string oAuthToken, string oAuthSecret, string lastTweet)
        {
            string url = HOME_TIMELINE;

            if (!string.IsNullOrEmpty(lastTweet))
            {
                url += "?since_id=" + lastTweet.Trim();
            }

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

            request.Method = HttpMethod.GET.ToString();

            string nonce     = OAuthHelper.GetNonce();
            string timestamp = OAuthHelper.GetTimestamp();

            Dictionary <string, string> parms = GetTimelineParms(nonce, timestamp, oAuthToken, lastTweet);
            string signatureBase = OAuthHelper.SignatureBsseString(request.Method, HOME_TIMELINE, parms);
            string signature     = OAuthHelper.SignBaseString(signatureBase, oAuthSecret);
            string authHeader    = OAuthHelper.AuthorizationHeader(nonce, signature, timestamp, oAuthToken);

            request.Headers.Add(Constants.AUTHORIZATION, authHeader);
            request.ContentType = Constants.CONTENT_TYPE.X_WWW_FORM_URLENCODED;
            request.ServicePoint.Expect100Continue = false;
            request.UserAgent = Constants.USER_AGENT;

            return(request);
        }
Esempio n. 2
0
        static HttpWebRequest GetUpdateStatusRequest(string oAuthToken, string oAuthSecret, string encodedStatus, string replyId, string media = null)
        {
            string url = UPDATE_STATUS;

            if (!string.IsNullOrEmpty(replyId))
            {
                url += "?in_reply_to_status_id=" + replyId;
            }

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

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

            string nonce     = OAuthHelper.GetNonce();
            string timestamp = OAuthHelper.GetTimestamp();

            Dictionary <string, string> parms = GetUpdateStatusParms(nonce, timestamp, oAuthToken, encodedStatus, replyId, media);
            string signatureBase = OAuthHelper.SignatureBsseString(request.Method, UPDATE_STATUS, parms);
            string signature     = OAuthHelper.SignBaseString(signatureBase, oAuthSecret);
            string authHeader    = OAuthHelper.AuthorizationHeader(nonce, signature, timestamp, oAuthToken, true);

            request.Headers.Add(Constants.AUTHORIZATION, authHeader);
            request.ContentType = Constants.CONTENT_TYPE.X_WWW_FORM_URLENCODED;
            request.ServicePoint.Expect100Continue = false;
            request.UserAgent = Constants.USER_AGENT;

            return(request);
        }
Esempio n. 3
0
        static HttpWebRequest GetUpdateMediaStatusRequest(string oAuthToken, string oAuthSecret)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UPDATE_MEDIA_STATUS);

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

            string nonce     = OAuthHelper.GetNonce();
            string timestamp = OAuthHelper.GetTimestamp();

            Dictionary <string, string> parms = GetUpdateStatusParms(nonce, timestamp, oAuthToken, null, null);
            string signatureBase = OAuthHelper.SignatureBsseString(request.Method, UPDATE_MEDIA_STATUS, parms);
            string signature     = OAuthHelper.SignBaseString(signatureBase, oAuthSecret);
            string authHeader    = OAuthHelper.AuthorizationHeader(nonce, signature, timestamp, oAuthToken, true);

            request.Headers.Add(Constants.AUTHORIZATION, authHeader);
            request.ContentType = Constants.CONTENT_TYPE.FORM_DATA;
            request.ServicePoint.Expect100Continue = false;
            request.UserAgent = Constants.USER_AGENT;

            return(request);
        }