我已经尝试了许多不同的方法,并在互联网上搜索了教程,以了解如何使用OAuth的JTwitter。以下是我已经完成的步骤:
下载JTwitter和Signpost
将它们添加为Java Builder中的Jars
创建一个简单的按钮来运行它
public class ShareGenerator extends Activity {
private static final String JTWITTER_OAUTH_KEY = "this_is_populated";
private static final String JTWITTER_OAUTH_SECRET = "this_is_populated";
Button menupopButton;
@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.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
TwitterSend();
}
});
}
我有我的类
public void TwitterSend () {
OAuthSignpostClient client = new OAuthSignpostClient(JTWITTER_OAUTH_KEY, JTWITTER_OAUTH_SECRET, "oob");
Twitter jtwit = new Twitter("bob", client);
// open the authorisation page in the user's browser
client.authorizeDesktop();
// get the pin
String v = client.askUser("Please enter the verification PIN from Twitter");
client.setAuthorizationCode(v);
// Optional: store the authorisation token details
Object accessToken = client.getAccessToken();
// use the API!
jtwit.setStatus("Messing about in Java");
}
然而,我无法让OAuth屏幕弹出。 当它到达那里时就会崩溃。 有人能帮助我至少看到OAuth屏幕吗? 我已经正确设置了导入。