upload image to twitter with twitterizer

663 views Asked by At

I try to upload image with my tweet in twitterizer component.I send tweet without any error but UpdateWithMedia Has Error. I think this happen because My Request Url Is "https://upload.twitter.com/1/statuses/update_with_media.json" while Shoujd be "https://upload.twitter.com/1.1/statuses/update_with_media.json". How can i change My RequestUrl. My Contetnt Error is : "{"errors":[{"message":"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.","code":64}]}"

I see many solution in stackoverflow But it was not any thing to solve this problem

var oauth_consumerkey = "UEI02iC13cR8o8rgNyLpBpOmW";
        var oauth_consumersecret = "RaTQoZaxq51eHR51TbTKK762eSu5u5s7FoPPswyWMJlscuC6j0";
        const string callbackurl = "http://localhost:2008/WebForm1.aspx";
        if (Request["oauth_token"] == null)
        {
            OAuthTokenResponse reqtoken = OAuthUtility.GetRequestToken(
                oauth_consumerkey,
                oauth_consumersecret,
                callbackurl);

            Response.Redirect(string.Format("http://twitter.com/oauth/authorize?oauth_token={0}", reqtoken.Token));
        }
        else
        {
            string requesttoken = Request["oauth_token"].ToString();
            string pin = Request["oauth_verifier"].ToString();

            var token = OAuthUtility.GetAccessToken(
                oauth_consumerkey,
                oauth_consumersecret,
                requesttoken,
                pin);

            OAuthTokens accesstoken = new OAuthTokens()
            {
                AccessToken = token.Token,
                AccessTokenSecret = token.TokenSecret,
                ConsumerKey = oauth_consumerkey,
                ConsumerSecret = oauth_consumersecret
            };

            byte[] photo = ImageToByteArray("C:\\black_arrow.png");
            TwitterResponse<TwitterStatus> response = TwitterStatus.UpdateWithMedia(accesstoken, "Testing!! Send Image", photo, new StatusUpdateOptions() { UseSSL = true, APIBaseAddress = "http://api.twitter.com/1.1/" });
            if (response.Result == RequestResult.Success)
            { Response.Write("OK"); }
            else
            { Response.Write("Faild"); }
        }
1

There are 1 answers

0
hossein andarkhora On

solved, I've used the latest version of which was in Nuget, apparently has a problem. This time, instead of using these tools,i use the open-source project twittrizer from git and added as reference to the project and my problem was solved. many Thanks to @DigitallyBorn, who had helped on this subject. get open source twittrizer from www.twitterizer.net