在我的应用程序中,我需要通过Facebook和Twitter分享促销网站的链接,在Facebook我们得到像
“share dialog”或发布捆绑像
Request request = new Request(Session.getActiveSession(),"me/Feed",bundle,HttpMethod.POST,new Request.Callback(){ @Override public void onCompleted(Response response) { ... } });
但是Android没有twitter sdk(我使用twitter4j)并且无法发布捆绑
那么如何通过Twitter发推文链接?
解决方法
如果您发送的文字包含“这是我们的链接:
https://stackoverflow.com”这样的链接 – 推特会理解它并从您的链接中获取信息并显示 – 据我了解您需要在Twitter Feed中查看您认可的链接.
要发布链接,您可以像@Adrian Sicaru一样创建意图,或者使用twitter4j使用asynctask创建自己的自定义对话框,如下所示:
要发布链接,您可以像@Adrian Sicaru一样创建意图,或者使用twitter4j使用asynctask创建自己的自定义对话框,如下所示:
@Override protected Bundle doInBackground(Bundle... params) { Bundle args = params[0]; Bundle result = new Bundle(); String paramMessage = args.getString(MESSAGE); String paramLink = args.getString(LINK); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setoAuthConsumerKey("your ConsumerKey"); builder.setoAuthConsumerSecret("your ConsumerSecret"); String accesstoken = "your Token"; String accesstokenSecret = "your Secret"; TwitterFactory factory = new TwitterFactory(builder.build()); mTwitter = factory.getInstance(new Accesstoken(accesstoken,accesstokenSecret)); try { StatusUpdate status = new StatusUpdate(paramMessage); if (paramLink != null) { status = new StatusUpdate(paramMessage + " " + paramLink); } mTwitter.updateStatus(status); } catch (TwitterException e) { result.putString(RESULT_ERROR,e.getMessage()); } return result; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。