1.获取长期有效的token
1)请求链接
local url = string.format(“https://graph.facebook.com/v7.0/oauth/access_token?grant_type=fb_exchange_token&client_id=%s&client_secret=%s&fb_exchange_token=%s&access_token=%s”,
“你的应用编号”,
“你的应用密钥”,
“登陆时获取到的token”,
“登陆时获取到的token”)
2)返回值
{
“access_token”: “xxxxxxxxxxxxxx”,
“token_type”: “bearer”,
“expires_in”: 5127264
}
access_token:令牌
token_type:类型
expires_in:有效时间
2.获取facebook头像
1)请求链接
local url = string.format(“https://graph.facebook.com/v7.0/me?fields=picture&access_token=%s”,“你的token”)
2)返回值
{
“picture”: {
“data”: {
“height”: 50,
“is_silhouette”: false,
“url”: “xxxxxxxxxxxxxx”,
“width”: 50
}
},
“id”: “xxxxxxxx”
}
url:头像url
3.其他
获取名字,ID,性别等等,都可以去图谱API探索工具中去测试,会有返回值,方便大家测试。
图谱API探索工具链接:https://developers.facebook.com/tools/explorer?method=GET&path=me%3Ffields%3Dpicture&version=v7.0
4."将你登入到此应用时出错,请稍后再试"的问题"
android下默认有个debug.keystore,在我们不设置签名文件时,不打包直接运行在设备上时会用这个。
facebook登陆时,调起app,会校验后台配置的keyhash,所以我们需要把这个默认的debug.keystore也加上,避免不用签名时直接连设备启动,导致出现“将你登入到此应用时出错,请稍后再试”
SHA值转换成hashkey:http://tomeko.net/online_tools/hex_to_base64.php