appcelerator facebook 获取用户名

appcelerator facebook get username

如何通过 appcelerator facebook 登录获取用户的 facebook 用户名

var fb = require('facebook');
fb.appid = "153xx364563xxxx";
fb.permissions = ['publish_stream']; // Permissions your app needs
fb.forceDialogAuth = true;
fb.addEventListener('login', function(e) {
if (e.success) {
    Ti.API.info("Success " + JSON.stringify(e));
    alert('Logged In');
} else if (e.error) {
    alert(e.error);
} else if (e.cancelled) {
    alert("Canceled");
}
});

我得到的只是ID和名字

Success {"success":true,"code":0,"data":"{\"name\":\"John Smith\",\"id\":\"10111182454657222\"}","uid":"10111182454657222","cancelled":false,"bubbles":true,"type":"login","source":{"id":"facebook","appid":"153xx364563xxxx","forceDialogAuth":true},"cancelBubble":false}

publish_stream 权限已经弃用很多年了,再也没有办法获得 username 了。 publish_stream 的替换将是 publish_actions,但您只需要 post 到用户墙的权限。

v2.0 更新日志:

/me/username is no longer available.

来源:https://developers.facebook.com/docs/apps/changelog#v2_0

无论如何您都不需要用户名,只需使用(App Scoped)ID 来识别返回用户。