如何在.net上在Twitter上分享图像视频和文本 [英] How do I Share images videos and text on Twitter in .net

查看:74
本文介绍了如何在.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 = &quot;T3iyMyxKCCrJJMBYLIuAC14rz&quot;;//&quot;hhTc2SpEXM8seEpzL14wfzJaV&quot;;
            string oauth_consumer_secret = &quot;Yqx5dQGvXo9yyVJUAYZhEYmYKoD7o509MB3fRpQAFhRVm4yJKB&quot;;//&quot;8clhs2WnVDmgjkeDLkTVS1786HnTjBEM2WKzIjVheGGPJNmgMJ&quot;;

            if (Request[&quot;oauth_token&quot;] == null)
            {
                OAuthTokenResponse reqToken = OAuthUtility.GetRequestToken(oauth_consumer_key, oauth_consumer_secret, Request.Url.AbsoluteUri);
                Response.Redirect(string.Format(&quot;https://api.twitter.com/oauth/authorize?oauth_token={0}&quot;, reqToken.Token));
                //Response.Redirect(string.Format(&quot;https://api.twitter.com/1.1/oauth/authorize?oauth_token={0}&quot;, reqToken.Token));

            }
            else
            {
                string requestToken = Request[&quot;oauth_token&quot;].ToString();
                string pin = Request[&quot;oauth_verifier&quot;].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(@&quot;D:\Rajesh\img1.jpg&quot;);
                TwitterResponse&lt;TwitterStatus&gt; response = TwitterStatus.UpdateWithMedia(accesstoken, &quot;img&quot;, photo);
                if (response.Result == RequestResult.Success)
                {
                    Response.Write(&quot;This is YOUR PAGE&quot;);
                }
                else
                {
                    Response.Write(&quot;Try some other time&quot;);
                }

            }
        }

        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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆