Twitter 的回调 URL
我正在创建一个 Android 应用程序,其中我必须集成 twitter,以便使用 twitter4j 库在其上上传图片。
我无法在 Twitter 上为应用程序指定回调 Url。
请帮我。
I am creating an android application in which I have to integrate twitter for uploading picture on it using twitter4j library.
I am not able to specify callback Url on twitter for application.
Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Twitter 的情况下,您应该使用意图过滤器来获取回调,因为
在授权后您想要回调的活动中添加以下意图过滤器
,并且在您想要回调的活动(在本例中为 TwitterActivity)中,将您的验证程序作为
这里需要注意的重要一点是
->首先,您通过调用 Web api 来请求请求令牌
->该请求令牌可用于授权您的用户
->授权后,您的浏览器加载特定的 URL,该 URL 可以启动您的活动,因为您已使用相应的主机名和方案名称(即 host =“oauth”,scheme=“com.example.twitter”)将意图过滤器添加到您的活动中
->您可以从加载的 Url 中获取访问令牌,即从中提取验证程序并使用您的请求令牌
获取详细代码,请访问 https://bitbucket.org/hintdesk/android-how-to-tweet-in-twitter-within-android-client/src/f8923a4a641313cae7243da51530b472730c2439?at=default
You should use intent filters to get callback in case of twitter as
To the activity where you want to get you callback after authorization add following intent filter
And in your Activity where you want to get callback to (in this case TwitterActivity) get your verifier as
Here important thing to notice is
-> first of all you ask for request token by calling web api
-> that request token can used to authorize your user
-> after authorization you browser loads certain Url which can start your activity as you have added intent-filter to your activity with corresponding host name and scheme name (i.e. host = "oauth", scheme="com.example.twitter")
-> you can get you access tokens from the loaded Url i.e. extracting verifier from it and using your request token
for detail code please visit https://bitbucket.org/hintdesk/android-how-to-tweet-in-twitter-within-android-client/src/f8923a4a641313cae7243da51530b472730c2439?at=default