Appcelerator Android Facebook 登录错误代码 2500
Appcelerator Android Facebook login error code 2500
Little Appcelerator Facebook 登录问题 Android API 6.2.0。 Facebook 登录屏幕显示。我登录没问题。它说我之前已经通过 Facebook 授予了该应用程序的许可。我点击"Continue"。然后我得到这个错误代码 2500。这是日志:
// I added the X's to the token & uid for this log
[DEBUG] : TiFacebookModule: (main) [1,298128] authorize called, permissions length: 1
[DEBUG] : TiFacebookModule: (main) [1,298129] authorizing permission: email
[DEBUG] : ActivityWorkerProxy: (main) [27137,325266] ActivityWorkerProxy onActivityResult
[DEBUG] : TiFacebookModule: (main) [251,325517] user is not null
[DEBUG] : TiFacebookModule: (main) [0,325517] firing login event from module
[WARN] : TiFacebookModule: (main) [0,325517] The getCanPresentOpenGraphActionDialog property is deprecated. This always returns true.
[DEBUG] : TiFacebookModule: (main) [1,325518] get accessToken
[WARN] : TiFacebookModule: (main) [0,325518] The getCanPresentShareDialog property is deprecated. This always returns true.
[INFO] : Facebook: SUCCESS // {"type":"login","source":{"loggedIn":true,"canPresentOpenGraphActionDialog":true,"permissions":["email","public_profile"],"accessToken":"EAADVQzAhldwBAN3ZCLDyeVF6NiWoIxLV1x8KTeAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXifLwjJPSDE7BFckLwMxJPmTu3BecteHVyutEc2uxbTV4ccG6OciIIOsXpTpewNlZC5hJkV1l0NtsjrFZARKdZBABOcZASPHjs0XZA6o9JRqlwkAX2S40ZCG0AqzsZD","loginBehavior":null,"canPresentShareDialog":true,"expirationDate":"2018-01-10T21:22:24.457Z","uid":"1163XXXXXXX6528","apiName":"Ti.Module","bubbleParent":true,"invocationAPIs":[{"namespace":"Facebook","api":"createActivityWorker"},{"namespace":"Facebook","api":"createLikeButton"},{"namespace":"Facebook","api":"createLoginButton"}],"__propertiesDefined__":true,"_events":{"login":{}}},"data":"{\"id\":\"1163XXXXXXX6528\",\"name\":\"Byte Bbt\"}","uid":"1163XXXXXXX6528","cancelled":false,"bubbles":false,"success":true,"code":0,"cancelBubble":false}
[INFO] : me?fields=name,email,first_name,last_name
[ERROR] : TiFacebookModule: (main) [70,325588] requestWithGraphPath callback error: An active access token must be used to query information about the current user.
[INFO] : results From Graph API: {"error":"An error code 2500 has occured. An active access token must be used to query information about the current user."}
[ERROR] : TiExceptionHandler: (main) [2,325590] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,325590] - In undefined:1,1
[ERROR] : TiExceptionHandler: (main) [0,325590] - Message: Uncaught SyntaxError: Unexpected token u in JSON at position 0
[ERROR] : TiExceptionHandler: (main) [0,325590] - Source: undefined
同样的代码在 iOS:
上完美运行
var fb = require('facebook');
$.index.fbProxy = fb.createActivityWorker({lifecycleContainer: $.index});
fb.permissions = ['email'];
fb.initialize();
fb.addEventListener('login', function(e) {
if (e.success) {
Ti.App.FBuid = e.uid;
Ti.App.FBtoken = e.source.accessToken;
Ti.App.FBname = JSON.parse(e.data).name;
Ti.API.info('Facebook: SUCCESS // ' + JSON.stringify(e));
// This test didn't work
// "me?accessToken=" + Ti.App.FBtoken + "&uid=" + Ti.App.FBuid + "&u=" + Ti.App.FBuid + "&fields=name,email,first_name,last_name"
Ti.API.info("me?fields=name,email,first_name,last_name");
fb.requestWithGraphPath("me?fields=name,email,first_name,last_name", {}, 'GET', function(result) {
Ti.API.info('results From Graph API: ' + JSON.stringify(result));
var data = JSON.parse(result.result);
Ti.API.info("-- email: " + data.email);
Ti.App.FBemail = data.email;
Ti.App.FBfname = data.first_name;
Ti.App.FBlname = data.last_name;
});
} else if (e.cancelled) {
Ti.API.info('Facebook: FAIL');
} else {
$.blackout.hide();
Ti.API.info('Facebook: ERROR // ' + e.error);
alert("Oops. Something went wrong.\nPlease try again.");
}
});
fb.authorize();
知道如何摆脱这个 "active access token" 2500 错误吗?谢谢
我猜你正在使用旧格式将字段传递给 requestGraphApi。
试试这个,我已将您的代码格式化如下:
var fb = require('facebook');
// set permissions first
fb.permissions = ['public_profile', 'email'];
// then add event listener
fb.addEventListener('login', facebookLogin);
// finally initialize
fb.initialize();
// attach proxy after initialisation
$.index.fbProxy = fb.createActivityWorker({lifecycleContainer: $.index});
// Pass fields as dictionary to be comaptible with latest graph api.
function facebookLogin(e) {
if (e.success) {
Ti.App.FBuid = e.uid;
// I think you don't need accessToken to store, Facebook module will use it properly when you call graph api.
Ti.App.FBtoken = e.source.accessToken;
Ti.App.FBname = JSON.parse(e.data).name;
// pass fields as dictionary
fb.requestWithGraphPath("me", {fields:'name,email,first_name,last_name,gender', 'GET', function(result) {
Ti.API.info('results From Graph API: ' + JSON.stringify(result));
var data = JSON.parse(result.result);
Ti.API.info("-- email: " + data.email);
// this is not recommended approach to modify internal api Ti.App
Ti.App.FBemail = data.email;
Ti.App.FBfname = data.first_name;
Ti.App.FBlname = data.last_name;
});
} else if (e.cancelled) {
Ti.API.info('Facebook: FAIL');
} else {
$.blackout.hide();
Ti.API.info('Facebook: ERROR // ' + e.error);
alert("Oops. Something went wrong.\nPlease try again.");
}
}
fb.authorize();
Little Appcelerator Facebook 登录问题 Android API 6.2.0。 Facebook 登录屏幕显示。我登录没问题。它说我之前已经通过 Facebook 授予了该应用程序的许可。我点击"Continue"。然后我得到这个错误代码 2500。这是日志:
// I added the X's to the token & uid for this log
[DEBUG] : TiFacebookModule: (main) [1,298128] authorize called, permissions length: 1
[DEBUG] : TiFacebookModule: (main) [1,298129] authorizing permission: email
[DEBUG] : ActivityWorkerProxy: (main) [27137,325266] ActivityWorkerProxy onActivityResult
[DEBUG] : TiFacebookModule: (main) [251,325517] user is not null
[DEBUG] : TiFacebookModule: (main) [0,325517] firing login event from module
[WARN] : TiFacebookModule: (main) [0,325517] The getCanPresentOpenGraphActionDialog property is deprecated. This always returns true.
[DEBUG] : TiFacebookModule: (main) [1,325518] get accessToken
[WARN] : TiFacebookModule: (main) [0,325518] The getCanPresentShareDialog property is deprecated. This always returns true.
[INFO] : Facebook: SUCCESS // {"type":"login","source":{"loggedIn":true,"canPresentOpenGraphActionDialog":true,"permissions":["email","public_profile"],"accessToken":"EAADVQzAhldwBAN3ZCLDyeVF6NiWoIxLV1x8KTeAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXifLwjJPSDE7BFckLwMxJPmTu3BecteHVyutEc2uxbTV4ccG6OciIIOsXpTpewNlZC5hJkV1l0NtsjrFZARKdZBABOcZASPHjs0XZA6o9JRqlwkAX2S40ZCG0AqzsZD","loginBehavior":null,"canPresentShareDialog":true,"expirationDate":"2018-01-10T21:22:24.457Z","uid":"1163XXXXXXX6528","apiName":"Ti.Module","bubbleParent":true,"invocationAPIs":[{"namespace":"Facebook","api":"createActivityWorker"},{"namespace":"Facebook","api":"createLikeButton"},{"namespace":"Facebook","api":"createLoginButton"}],"__propertiesDefined__":true,"_events":{"login":{}}},"data":"{\"id\":\"1163XXXXXXX6528\",\"name\":\"Byte Bbt\"}","uid":"1163XXXXXXX6528","cancelled":false,"bubbles":false,"success":true,"code":0,"cancelBubble":false}
[INFO] : me?fields=name,email,first_name,last_name
[ERROR] : TiFacebookModule: (main) [70,325588] requestWithGraphPath callback error: An active access token must be used to query information about the current user.
[INFO] : results From Graph API: {"error":"An error code 2500 has occured. An active access token must be used to query information about the current user."}
[ERROR] : TiExceptionHandler: (main) [2,325590] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [0,325590] - In undefined:1,1
[ERROR] : TiExceptionHandler: (main) [0,325590] - Message: Uncaught SyntaxError: Unexpected token u in JSON at position 0
[ERROR] : TiExceptionHandler: (main) [0,325590] - Source: undefined
同样的代码在 iOS:
上完美运行var fb = require('facebook');
$.index.fbProxy = fb.createActivityWorker({lifecycleContainer: $.index});
fb.permissions = ['email'];
fb.initialize();
fb.addEventListener('login', function(e) {
if (e.success) {
Ti.App.FBuid = e.uid;
Ti.App.FBtoken = e.source.accessToken;
Ti.App.FBname = JSON.parse(e.data).name;
Ti.API.info('Facebook: SUCCESS // ' + JSON.stringify(e));
// This test didn't work
// "me?accessToken=" + Ti.App.FBtoken + "&uid=" + Ti.App.FBuid + "&u=" + Ti.App.FBuid + "&fields=name,email,first_name,last_name"
Ti.API.info("me?fields=name,email,first_name,last_name");
fb.requestWithGraphPath("me?fields=name,email,first_name,last_name", {}, 'GET', function(result) {
Ti.API.info('results From Graph API: ' + JSON.stringify(result));
var data = JSON.parse(result.result);
Ti.API.info("-- email: " + data.email);
Ti.App.FBemail = data.email;
Ti.App.FBfname = data.first_name;
Ti.App.FBlname = data.last_name;
});
} else if (e.cancelled) {
Ti.API.info('Facebook: FAIL');
} else {
$.blackout.hide();
Ti.API.info('Facebook: ERROR // ' + e.error);
alert("Oops. Something went wrong.\nPlease try again.");
}
});
fb.authorize();
知道如何摆脱这个 "active access token" 2500 错误吗?谢谢
我猜你正在使用旧格式将字段传递给 requestGraphApi。
试试这个,我已将您的代码格式化如下:
var fb = require('facebook');
// set permissions first
fb.permissions = ['public_profile', 'email'];
// then add event listener
fb.addEventListener('login', facebookLogin);
// finally initialize
fb.initialize();
// attach proxy after initialisation
$.index.fbProxy = fb.createActivityWorker({lifecycleContainer: $.index});
// Pass fields as dictionary to be comaptible with latest graph api.
function facebookLogin(e) {
if (e.success) {
Ti.App.FBuid = e.uid;
// I think you don't need accessToken to store, Facebook module will use it properly when you call graph api.
Ti.App.FBtoken = e.source.accessToken;
Ti.App.FBname = JSON.parse(e.data).name;
// pass fields as dictionary
fb.requestWithGraphPath("me", {fields:'name,email,first_name,last_name,gender', 'GET', function(result) {
Ti.API.info('results From Graph API: ' + JSON.stringify(result));
var data = JSON.parse(result.result);
Ti.API.info("-- email: " + data.email);
// this is not recommended approach to modify internal api Ti.App
Ti.App.FBemail = data.email;
Ti.App.FBfname = data.first_name;
Ti.App.FBlname = data.last_name;
});
} else if (e.cancelled) {
Ti.API.info('Facebook: FAIL');
} else {
$.blackout.hide();
Ti.API.info('Facebook: ERROR // ' + e.error);
alert("Oops. Something went wrong.\nPlease try again.");
}
}
fb.authorize();