简体   繁体   English

Windows Phone的Twitter API升级

[英]Twitter API upgrade for Windows Phone

I have tweet poster in my application which uses oAuth 1.0 which will retire soon and will be non functional. 我在使用oAuth 1.0的应用程序中发布了推文海报,该海报很快就会退休,并且将无法使用。 I have to upgrade my API to 1.1 . 我必须将API升级到1.1 Twitter development center says that, If oAuth is used by your application, you can easily transaction to 1.1 by only updating your API endpoint. Twitter开发中心说,如果您的应用程序使用了oAuth,则只需更新API端点即可轻松地将事务转换为1.1 What exactly is API endpoint? API端点到底是什么?

Here I'm having hard understanding about API endpoint. 在这里,我对API端点很难理解。 I think my asyncronous post call URL must be upgraded. 我认为必须升级我的异步邮寄URL。

Here is the relevant codes which I think that might include the answer; 这是我认为可能包含答案的相关代码;

private void btnPostTweet_Click(object sender, RoutedEventArgs e)
    {
        namebocx.Text = userScreenName;
        if (txtBoxNewTweet.Text.Trim().Length == 0) { return; }

        var credentials = new OAuthCredentials
        {
            Type = OAuthType.ProtectedResource,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            ConsumerKey = TwitterSettings.consumerKey,
            ConsumerSecret = TwitterSettings.consumerKeySecret,
            Token = this.accessToken,
            TokenSecret = this.accessTokenSecret,
            Version = "1.0"
        };

        var restClient = new RestClient
        {
            Authority = TwitterSettings.StatusUpdateUrl,
            HasElevatedPermissions = true,
            Credentials = credentials,
            Method = WebMethod.Post
        };

        restClient.AddHeader("Content-Type", "application/x-www-form-urlencoded");

        // Create a Rest Request and fire it
        var restRequest = new RestRequest
        {
            Path = "1/statuses/update.xml?status=" + txtBoxNewTweet.Text //Here must be endpoint of Api??
        };

        var ByteData = Encoding.UTF8.GetBytes(txtBoxNewTweet.Text);
        restRequest.AddPostContent(ByteData);
        restClient.BeginRequest(restRequest, new RestCallback(PostTweetRequestCallback));
    }
}

and also here is the authentication settings: 这也是身份验证设置:

public class TwitterSettings
{
    public static string RequestTokenUri = "https://api.twitter.com/oauth/request_token";
    public static string AuthorizeUri = "https://api.twitter.com/oauth/authorize";
    public static string AccessTokenUri = "https://api.twitter.com/oauth/access_token";

    public static string CallbackUri = "http://www.google.com";

    public static string StatusUpdateUrl { get { return "http://api.twitter.com"; } }


    public static string consumerKey = "myconsumerkeyhere";
    public static string consumerKeySecret = "myconsumersecrethere";

    public static string oAuthVersion = "1.0a";
}

Here what twitter says me to replace with this instead of written in my code; 这里是Twitter告诉我的内容,而不是用我的代码编写; https://api.twitter.com/1.1/statuses/update.json and some parameters told here -->> https://dev.twitter.com/docs/api/1.1/post/statuses/update https://api.twitter.com/1.1/statuses/update.json和此处介绍的一些参数->> https://dev.twitter.com/docs/api/1.1/post/statuses/update

How should I update my API endpoint, what kind of changes do I have to do? 我应该如何更新我的API端点,我必须做哪些更改?

If you can help me, I really appreciate 如果可以帮助我,我真的很感激

You can change this: 您可以更改此:

Path = "1/statuses/update.xml?status=" + txtBoxNewTweet.Text 
//Here must be endpoint of Api??

to this: 对此:

Path = "1.1/statuses/update.json?status=" + txtBoxNewTweet.Text 
//Here must be endpoint of Api??

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM