Android Twitter集成 – 卡在登录页面?

Android Twitter集成 – 卡在登录页面?,第1张

概述我有一个以前的Android应用程序的代码,我成功地与Twitter集成.我已将此代码复制到新应用程序并更改了我的新应用程序的callback-url,consumer-key和consumer-secret.使用twitter4j库我可以获得我的RequestToken和身份验证URL,如下所示:Twittertwitter=newTwitterFactory().ge

我有一个以前的Android应用程序的代码,我成功地与Twitter集成.我已将此代码复制到新应用程序并更改了我的新应用程序的callback-url,consumer-key和consumer-secret.

使用twitter4j库我可以获得我的RequestToken和身份验证URL,如下所示:

Twitter twitter = new TwitterFactory().getInstance();twitter.setoAuthConsumer(myConsumerKey, myConsumerSecret);RequestToken requestToken = twitter.getoAuthRequestToken(myCallbackUrl);String authenticationUrl = requestToken.getAuthenticationURL()

RequestToken具有非空令牌值,非null tokenSecret值和null secretKeySpec值.身份验证网址格式如下:

http://API.twitter.com/oauth/authenticate?oauth_token=...

我在我的WebVIEw中加载此URL,我看到以下页面

在这里,我被困住了.当我单击“登录”按钮时,只是同一页面继续加载.没有其他的.当我单击取消按钮时,我看到以下页面:

只有在这个页面上,当我点击返回粉丝联盟Beko BBL按钮是我的callback-url被调用,带有被拒绝的参数,其中我的oauth_token为其值.之前有人看过这样的东西,知道什么可能阻止我的签名请求被处理???

Update 1: I’ve trIEd the authentication url and the Sign In button from a desktop browser and it works as expected, processing the response and then invoking the callback-url. It’s just failing when trying it in the WebVIEw of my AndroID app. I’ve trIEd it on multiple AndroID devices and tablets. JavaScript is enabled on my WebVIEw too so that’s not it. IDeas most welcome. I’m out of IDeas!

Update 2: I’ve just done some deBUG-mode code-tracing on my WebVIEw‘s WebVIEwClIEnt and I’m seeing that when I click the Sign In button, the shouldOverrIDeUrlLoading(WebVIEw webVIEw, String url) method is not called, but the following three methods are called (in order): onPageStarted(WebVIEw vIEw, String url, Bitmap favicon), onLoadResource(WebVIEw vIEw, String url), onPageFinished(WebVIEw vIEw, String url). The url value these methods have is: https://API.twitter.com/oauth/authenticate, i.e. the oauth_token parameter has been stripped off the authenticate url. Maybe this is a POST request being treated as a GET request and hence why this one same page keeps loading up? Any IDeas what I can do to have this Sign In button press processed properly?

解决方法:

我想你忘了从twitter app控制面板设置一个回调网址.

登录twitter API部分,选择您的应用程序并转到设置选项卡.

如果不这样做,当用户按下登录时,不会发生重定向,因此您将无法捕获验证程序.

另一方面,当您设置回调网址时,您的网页视图可以拦截重定向.

注意:您可以设置您想要的任何URL,重要的是捕获传递给重定向URL的oauth_verifIEr参数.

在那种情况下你的

shouldOverrIDeUrlLoading

应该被触发.

总结

以上是内存溢出为你收集整理的Android Twitter集成 – 卡在登录页面?全部内容,希望文章能够帮你解决Android Twitter集成 – 卡在登录页面?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1106428.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存