采用Android发送的tweet [英] Sending tweets using Android
本文介绍了采用Android发送的tweet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以电话我如何使用Android的鸣叫?
我如何可以使用Android发送鸣叫?
Can anyone tel me how to tweet using Android? How can i send tweets using Android?
推荐答案
您想要的东西的如的这样的:
You want something like this:
mHttpClient = new DefaultHttpClient();
mCredentials = new UsernamePasswordCredentials("username", "password");
mHttpClient.getCredentialsProvider().setCredentials(
new AuthScope("twitter.com", 80, "Twitter API"),
mCredentials);
HttpPost post = new HttpPost("http://twitter.com/statuses/update.xml");
HttpParams params = post.getParams();
HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY);
HttpProtocolParams.setUseExpectContinue(params, false);
post.setParams(params);
ArrayList<NameValuePair> form = new ArrayList<NameValuePair>();
form.add(new BasicNameValuePair("status", "I'm tweeting!"));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(form);
post.setEntity(ent);
HttpResponse resp = mHttpClient.execute(post);
(从我自己的code撕开,并剥离下来的简洁一点。它不会编译原样!)
(Ripped from my own code, and stripped down a little bit for brevity. It won't compile as-is!)
这篇关于采用Android发送的tweet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文