It is possible to publish a status (programmatically) on Twitter or Facebook using the official applications installed on the phone?
我需要我的应用程序在Twitter和Facebook上发布新状态,但是我需要在不将用户认证为Facebook或Twitter的情况下进行此操作。我需要使用手机上安装的官方Facebook和Twitter应用程序。首先,我的应用程序应与这些应用程序连接。之后,我的应用程序必须检查用户是否使用正式的Facebook或Twitter应用程序登录,然后,我的应用程序必须使用正式的Facebook和Twitter应用程序发送新状态。
有可能做到吗?
不,不应该这样做,因为它会允许恶意应用程序使用其他其他应用程序的方法来发布或检索任何类型的信息。但是,可以使用Intent,通过消息将其发送给用户到Twitter或Facebook应用程序,然后让用户自己提交。
要使用Intent,以下功能应为您提供帮助:
1 2 3 4 5 6 7 8 9 | public void share(String subject,String text) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); startActivity(Intent.createChooser(intent, getString(R.string.share))); } |
您还可以过滤向用户显示哪些应用并进行一些自定义:
http://www.dev-articles.com/article/Facebook-share-intent-436001