使用 Fabric SDK 无效 JSON

Invalid JSON with use Fabric SDK

我使用这段代码并发现错误:

//我都是按照说明书做的

loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
    loginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {                
            Result<TwitterSession> result1 = result;
        }

        @Override
        public void failure(TwitterException exception) {                
            exception.printStackTrace(); // I catch this exception
        }
    });

这是我的日志:

01-26 12:39:10.258  32298-32298/com.DriverNotes.AndroidMobileClient E/Twitter﹕ Invalid json: <?xml version="1.0" encoding="UTF-8"?>
    <hash>
    <error>Desktop applications only support the oauth_callback value 'oob'</error>
    <request>/oauth/request_token</request>
    </hash>
    com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8
            at com.google.gson.JsonParser.parse(JsonParser.java:65)
            at com.google.gson.JsonParser.parse(JsonParser.java:45)
            at com.twitter.sdk.android.core.TwitterApiException.parseErrorCode(TwitterApiException.java:107)
            at com.twitter.sdk.android.core.TwitterApiException.readErrorCode(TwitterApiException.java:96)
            at com.twitter.sdk.android.core.TwitterApiException.<init>(TwitterApiException.java:43)
            at com.twitter.sdk.android.core.TwitterApiException.convert(TwitterApiException.java:81)
            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:725)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5279)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8
            at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505)
            at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386)

P.S。我希望能提供足够的问题信息

从错误来看,您的 Twitter 应用程序可能需要一些额外的信息才能正常工作。看看这个:

https://twittercommunity.com/t/desktop-applications-only-support-the-oauth-callback-value-oob-oauth-request-token/252/2

如果它仍然相关 - 我遇到了同样的问题,解决方案是在 app web page.

中设置 redirect_url 字段

并且您还必须取消选中文本框: "Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)"