我正在尝试在我的Android应用程序中实现twitter登录.
我按照说明(https://dev.twitter.com/twitter-kit/android/twitter-login).
如果我安装了Twitter应用程序,一切正常,但如果我点击登录按钮时没有,我会得到以下例外.
它打开了一个webvIEw,要求登录.
任何提示?
06-02 11:22:23.531 24124-24124/it.quepasa W/dalvikvm: VFY: unable to resolve virtual method 39779: Lretrofit/clIEnt/OkClIEnt;.openConnection (Lretrofit/clIEnt/Request;)Ljava/net/httpURLConnection;06-02 11:22:23.611 24124-24124/it.quepasa E/Twitter﹕ Failed to get request tokencom.twitter.sdk.androID.core.TwitterapIException: method POST must have a request body. at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:400) at retrofit.RestAdapter$RestHandler.access0(RestAdapter.java:220) at retrofit.RestAdapter$RestHandler.obtainResponse(RestAdapter.java:278) at retrofit.CallbackRunnable.run(CallbackRunnable.java:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at retrofit.Platform$AndroID.run(Platform.java:142) at java.lang.Thread.run(Thread.java:838)06-02 11:22:23.686 24124-24124/it.quepasa E/Twitter﹕ Authorization completed with an errorcom.twitter.sdk.androID.core.TwitterauthException: Failed to get request token at com.twitter.sdk.androID.core.IDentity.OAuthController.failure(OAuthController.java:78) at com.twitter.sdk.androID.core.internal.oauth.OAuth1aService.failure(OAuth1aService.java:198) at com.twitter.sdk.androID.core.Callback.failure(Callback.java:28) at retrofit.CallbackRunnable.run(CallbackRunnable.java:53) at androID.os.Handler.handleCallback(Handler.java:800) at androID.os.Handler.dispatchMessage(Handler.java:100) at androID.os.Looper.loop(Looper.java:194) at androID.app.ActivityThread.main(ActivityThread.java:5370) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method)
这里有我的代码:
AndroIDManifest.xml中:
<Meta-data androID:name="io.fabric.APIKey" androID:value="XXXXXXXX" />
MainActivity.java:
TwitterauthConfig authConfig = new TwitterauthConfig(TWITTER_KEY, TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig), new Crashlytics()); //I've trIEd without crashlytics, same problem. Crashlytics works..
LoginActivity.java:
loginbutton = (TwitterLoginbutton) findVIEwByID(R.ID.twitter_login_buttons); loginbutton.setCallback(new Callback<TwitterSession>() { @OverrIDe public voID success(Result<TwitterSession> result) { Log.d(TAG, "Success"); } @OverrIDe public voID failure(TwitterException exception) { Log.d(TAG, "Failure"); } });
@OverrIDe protected voID onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); loginbutton.onActivityResult(requestCode, resultCode, data); }
解决方法:
我找到了一个解决方案:
这是okhttp 2.4的一个重大变化,恢复到2.3解决了我的问题.
看到:
https://github.com/square/okhttp/issues/751
https://github.com/square/retrofit/issues/854
总结以上是内存溢出为你收集整理的java – 无法获取请求令牌方法POST必须具有请求正文全部内容,希望文章能够帮你解决java – 无法获取请求令牌方法POST必须具有请求正文所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)