我想在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.....
答案 0 :(得分:0)
来自文档,http://www.winterwell.com/software/jtwitter/javadoc/winterwell/jtwitter/OAuthSignpostClient.html,越界,基于桌面,在您的Android应用程序中无效。
我认为您应该使用xAuth,请参阅以下示例:Android Twitter xAuth example using twitter4j