appcelerator facebook获取用户名

时间:2016-02-15 10:29:03

标签: facebook facebook-graph-api username appcelerator-titanium

如何通过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}

1 个答案:

答案 0 :(得分:1)

多年以来,publish_stream权限已弃用,并且无法再获取usernamepublish_stream的替换为publish_actions,但您只需要该权限即可发布到用户墙。

v2.0的更新日志:

  

/ me / username不再可用。

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

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