【问题标题】:Twitter on Android exception communication timeoutTwitter on Android 异常通讯超时
【发布时间】:2011-03-22 09:41:57
【问题描述】:

我想在 Android 上制作一个关于 Twitter 的程序。

代码是这样的:

public class ShareGenerator extends Activity {
    private final static String JTWITTER_OAUTH_KEY = "********";
    private final static String JTWITTER_OAUTH_SECRET ="***********"
Button menupopButton;
TextView txShare;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share);
    this.setContentView(R.layout.share);
    this.txShare = (TextView) this.findViewById(R.id.lblshare);
    this.menupopButton = (Button) this.findViewById(R.id.menupop);
    menupopButton.setText("login");

    menupopButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)

        {
            OAuthSignpostClient client = new OAuthSignpostClient(JTWITTER_OAUTH_KEY, JTWITTER_OAUTH_SECRET, "oob");
            URI url = client.authorizeUrl();
            client.setAuthorizationCode("pin");  
                        String[] accessToken = client.getAccessToken();
                        Twitter jtwit = new Twitter("cnitwoker", client);
            jtwit.setStatus("Messing about in Java");

        }
    });

}

代码取自示例,但可能有问题。什么是“oob”?如何获得密码?

我收到以下错误:

:03-22 17:24:21.087: ERROR/AndroidRuntime(30260): winterwell.jtwitter.TwitterException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: The operation timed out.....

【问题讨论】:

    标签: android twitter


    【解决方案1】:

    来自文档,http://www.winterwell.com/software/jtwitter/javadoc/winterwell/jtwitter/OAuthSignpostClient.html,越界,基于桌面,无法在您的 Android 应用中运行。

    我认为您应该使用 xAuth,例如:Android Twitter xAuth example using twitter4j

    【讨论】:

    • 嗨,Fredrik Leijon,感谢您的回答,在此之前,我是否应该通过电子邮件发送 Twitter 支持以让他们为我的应用程序打开 xAuth?我只是得到 JTWITTER_OAUTH_KEY 和 JTWITTER_OAUTH_SECRET
    • 阅读dev.twitter.com/pages/xauth 似乎您需要要求为您的应用程序启用它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 2011-03-11
    • 2014-05-30
    • 1970-01-01
    • 1970-01-01
    • 2012-10-09
    • 1970-01-01
    相关资源
    最近更新 更多