【问题标题】:TweetSharp Authorization on WP7 (oAuth)WP7 上的 TweetSharp 授权 (oAuth)
【发布时间】:2011-06-04 16:41:40
【问题描述】:

我正在尝试制作一个 WP7 应用程序来发送用户想要的短消息。问题是我总是得到 Unauthorized 响应。这是我的工作:

首先,我初始化Service:

TwitterService twService;    
twService = new TwitterService(App.TwitterConsumerKey, App.TwitterConsumerSecret);
twService.AuthenticateWith(App.TwitterAccessToken, App.TwitterAccessTokenSecret);

如果我使用 SendTweet,我会收到 Unauthorized 响应(我猜这很合理 - 它不知道应该向哪个用户发送推文)。所以我必须以某种方式授权用户。我需要一个浏览器。我创建了一个并将其命名为 LoginBrowser。我该如何使用它?我想像这样得到 uri:

  twService.GetRequestToken((requestToken, response) =>
  {
    if(requestToken == null)
    {
    Console.WriteLine("Getting request token; response: {0}", response.StatusDescription);
    return;
    }
    var uri =  twService.GetAuthorizationUri(requestToken);
    if (uri == null)
      Console.WriteLine("uri is null");
    else
      Console.WriteLine("Uri: {0}", uri.ToString());

  }
  );

这不起作用。请求令牌等于 null 并且它打印出响应是 Unauthorized :|这样做的正确方法是什么?我发现的所有文档都没有编译。似乎 TweeSharp 刚刚更新,现在所有文档都已过时。

【问题讨论】:

标签: c# windows-phone-7 twitter authorization tweetsharp


【解决方案1】:

您有应用的 API 密钥吗? (http://dev.twitter.com/),我主要关注这个method,它运行良好。唯一的区别是我将 webbrowser 控件上的 IsScriptEnabled 属性设置为 false,因为 compatibility issue 但我在 twitter auth 页面之后通过代码重新启用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 2014-07-05
    • 2014-05-18
    • 1970-01-01
    • 2017-09-15
    • 2015-09-16
    • 2018-12-11
    相关资源
    最近更新 更多