我正试图通过Android应用程序在我的Twitter帐户上发布我的数据,所以我该怎么办呢。 我试过一种方法,下面是代码,并且它显示了我的帐户上的数据,我需要点击推文按钮来发送推文。所以我可以知道如何直接发布它而不要求我发推文。与Four Square app
一样public void open(View view){
String text = "Share Your Experiance ....!!!";
String url = "twitter://post?message=";
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url + Uri.encode(text)));
startActivity(i);
} catch (android.content.ActivityNotFoundException e) {
Toast.makeText(this, "Can't send tweet! Please install twitter...", 2).show();
}
提前致谢!!!
答案 0 :(得分:0)
首先,您必须检查是否使用Twitter登录后,根据您的条件,您可以应用此代码段。
我认为您在代码中遵循了Twitter集成的所有基础知识。
public void uploadPic(String message, String getImgUrl)
throws Exception {
try {
System.out.println(" ON UPLOAD PIC FUNCTION getImgUrl "+getImgUrl);
// URL url = new URL("http://faveplatewebservice.siplstudio.com/uploads/big_dish/oooo14n7464rO4_thumb.png");
URL url = new URL(getImgUrl);
URLConnection urlConnection = url.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
StatusUpdate status = new StatusUpdate("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message);
//status.setMedia(file);
status.setMedia("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message, in);
mTwitter.updateStatus(status);
} catch (TwitterException e) {
Log.d("TAG", "Pic Upload error" + e.getExceptionCode());
throw e;
}
}
希望它能帮助你!!
如果你卡在任何地方,请通知我。
Thankss !!