-1
我有一個提示,要求玩家將他的分數發送到Facebook遊戲的排行榜上。在Facebook上獲取玩家的名字
var playerName = prompt("You earned "+score.toString()+" points. Please enter your name:", "player");
$.get("scoreboard.php",{"player": playerName, "score": score.toString()})
.done(function(data){console.log(data);});
我應該實現什麼樣的代碼來自動從facebook上獲取他的名字併發送到我的數據庫?
我已經實現了:
function getMe(callback) {
FB.api('/me', {fields: 'id,name,first_name,picture.width(100).height(100)'}, function(response){
if(!response.error) {
friendCache.me = response;
callback();
} else {
console.error('/me', response);
}
});
,但我怎麼檢索playerName此信息????
This answer http://stackoverflow.com/a/5846796/1793718可能會有所幫助。 – Lucky
使用facebook SDK。 https://developers.facebook.com/docs/graph-api/reference/user –
如果這解決了你的問題,請張貼作爲答案。 – Lucky