我嘗試上傳圖片與twitterizer組件中的推文。我發送沒有任何錯誤的推文,但是UpdateWithMedia有錯誤。 我認爲這是因爲我的請求網址是「https://upload.twitter.com/1/statuses/update_with_media.json」而Shoujd是「https://upload.twitter.com/1.1/statuses/update_with_media.json」。 我如何更改我的RequestUrl。 我的競賽錯誤是:「{」errors「:[{」message「:」Twitter REST API v1不再有效。請遷移到API v1.1。 https://dev.twitter.com/docs/api/1.1/overview「」代碼「:64}]}」將圖片上傳到twitter與twitterizer
我看到許多計算器解決方案,但它並沒有解決這個問題
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"); }
}