如何在.net上在Twitter上分享图像视频和文本 [英] How do I Share images videos and text on Twitter in .net
本文介绍了如何在.net上在Twitter上分享图像视频和文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#Error:
{"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}]}
-------------------------------------------------------------------------------------
##, <pre lang="C#">private void CheckAuthorization()
{
try
{
string oauth_consumer_key = "T3iyMyxKCCrJJMBYLIuAC14rz";//"hhTc2SpEXM8seEpzL14wfzJaV";
string oauth_consumer_secret = "Yqx5dQGvXo9yyVJUAYZhEYmYKoD7o509MB3fRpQAFhRVm4yJKB";//"8clhs2WnVDmgjkeDLkTVS1786HnTjBEM2WKzIjVheGGPJNmgMJ";
if (Request["oauth_token"] == null)
{
OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(oauth_consumer_key, oauth_consumer_secret, Request.Url.AbsoluteUri);
Response.Redirect(string.Format("https://api.twitter.com/oauth/authorize?oauth_token={0}", reqToken.Token));
//Response.Redirect(string.Format("https://api.twitter.com/1.1/oauth/authorize?oauth_token={0}", reqToken.Token));
}
else
{
string requestToken = Request["oauth_token"].ToString();
string pin = Request["oauth_verifier"].ToString();
var tokens = OAuthUtility.GetAccessToken(oauth_consumer_key, oauth_consumer_secret, requestToken, pin);
OAuthTokens accesstoken = new OAuthTokens()
{
AccessToken = tokens.Token,
AccessTokenSecret = tokens.TokenSecret,
ConsumerKey = oauth_consumer_key,
ConsumerSecret = oauth_consumer_secret
};
byte[] photo = File.ReadAllBytes(@"D:\Rajesh\img1.jpg");
TwitterResponse<TwitterStatus> response = TwitterStatus.UpdateWithMedia(accesstoken, "img", photo);
if (response.Result == RequestResult.Success)
{
Response.Write("This is YOUR PAGE");
}
else
{
Response.Write("Try some other time");
}
}
}
catch (Exception ex)
{
throw ex;
}
}</pre>
推荐答案
Ridoy指出我是盲人,也许你也是;),错误消息说Twitter不再支持您的代码。您必须按照他们的文档更新它。
As Ridoy pointed out that I am blind, and perhaps you are too ;), the error message says that Twitter does not support your code anymore. You have to update it following their documentation.
这篇关于如何在.net上在Twitter上分享图像视频和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文