gpt4 book ai didi

java - 无法使用 Android SDK 3 连接到 Facebook

转载 作者:行者123 更新时间:2023-12-01 13:50:08 25 4
gpt4 key购买 nike

我尝试使用 Android SDK 3.0 连接到 Facebook,但收到如下授权错误。搜索发现这可能是生成的哈希值的问题,这确实是一个问题,然后我使用 this solution 并得到了一个不同的哈希值,我现在在 Facebook 应用程序中拥有它。错误仍然存​​在。

我在 Facebook 授权对话框出现之前收到此异常:

11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): Exception during service
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): com.facebook.http.protocol.ApiException: invalid app id
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:83)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:162)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:239)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:272)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:29)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:59)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:29)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:363)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:179)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:139)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:237)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:378)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:156)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:366)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:259)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:299)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:53)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:230)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Handler.handleCallback(Handler.java:725)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Handler.dispatchMessage(Handler.java:92)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Looper.loop(Looper.java:137)
11-17 13:11:50.698: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.HandlerThread.run(HandlerThread.java:60)

接受权限后我得到这个:

11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): Exception during service
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): com.facebook.http.protocol.ApiException: invalid app id
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:83)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:162)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:239)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:272)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:29)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:59)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:29)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:363)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:179)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:139)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:237)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:378)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:156)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:366)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:259)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:299)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:53)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:230)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Handler.handleCallback(Handler.java:725)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Handler.dispatchMessage(Handler.java:92)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.Looper.loop(Looper.java:137)
11-17 13:11:55.112: W/fb4a(:<default>):BlueServiceQueue(10043): at android.os.HandlerThread.run(HandlerThread.java:60)
11-17 13:11:55.456: D/dalvikvm(389): GC_EXPLICIT freed 2605K, 41% free 33304K/56164K, paused 146ms+12ms, total 497ms
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): Failed to send
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): com.facebook.fbservice.service.ServiceException: API_ERROR: API_ERROR
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:637)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:45)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at com.facebook.fbservice.ops.BlueServiceOperation$2.run(BlueServiceOperation.java:602)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at android.os.Handler.handleCallback(Handler.java:725)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at android.os.Handler.dispatchMessage(Handler.java:92)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at android.os.Looper.loop(Looper.java:137)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at android.app.ActivityThread.main(ActivityThread.java:5039)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at java.lang.reflect.Method.invoke(Method.java:511)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-17 13:11:55.464: W/fb4a(:<default>):GDPDialog(10043): at dalvik.system.NativeStart.main(Native Method)

但是,登录不起作用。

由于某些架构限制,我无法使用现有的 API,因此我已手动登录。这些是对 list 集的更改:

    <activity android:name="FBDemoStub"
android:theme="@style/CustomTheme"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTop"
android:label="FacebookDemo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
</activity>
<activity android:name="com.facebook.LoginActivity"/>

字符串 XML 包含 app_id,它是来自 Facebook 开发者控制台的编号,其中应用程序带有绿色圆圈(公共(public)且未沙盒)。

facebook 登录的实际代码是这样的(注意代码中的包名称是正确的):

public void login() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Session s = Session.getActiveSession();
if(s == null) {
Log.p("Creating new session");
s = new Session.Builder(activity).setApplicationId("com.myapp.package.name").build();
Session.setActiveSession(s);
}
if(s.isOpened()) {
Log.p("Login session already open");
return;
}
activity.setIntentResultListener(new IntentResultListener() {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Session s = Session.getActiveSession();
if(s != null) {
s.onActivityResult(activity, requestCode, resultCode, data);
}
}
});
Session.OpenRequest openRequest = new Session.OpenRequest(cn);
openRequest.setDefaultAudience(defaultAudience);
openRequest.setPermissions(permissions);
openRequest.setLoginBehavior(loginBehavior);
openRequest.setCallback(new Session.StatusCallback() {

@Override
public void call(Session session, SessionState state, Exception exception) {
if(exception != null) {
// ... do stuff
return;
}
if(state == SessionState.OPENED) {
FaceBookAccess.setToken(session.getAccessToken());
}
}
});

if (publish) {
s.openForPublish(openRequest);
} else {
s.openForRead(openRequest);
}
}
});
}

最佳答案

尝试更改此行

s = new Session.Builder(activity).setApplicationId("com.myapp.package.name").build();

s = new Session.Builder(activity).setApplicationId(getString(R.string.app_id)).build();

关于java - 无法使用 Android SDK 3 连接到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20030202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com