2012-08-31 35 views
1

因为我是新来的Facebook游戏有Flash游戏的任何第三方API。 其实我使用了mochi highscore API,但我不想通过年糕来登录。通过Facebook ID直接提交。让我知道任何第三方API或建议任何教程。Facebook的Flash游戏高分API

问候, chandu

回答

3

这是相当容易张贴分数在Facebook上高分,看看下面的代码。所有你需要的是你在登录用户时从facebook获得的用户ID,以及你在游戏中使用的值,比如经验值,积分或者其他值。

// post experience as score 
$experience = 1000; // get this from your database 
$contents = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=".FACEBOOK_APP_ID."&client_secret=".FACEBOOK_SECRET_KEY."&grant_type=client_credentials"); 

$exploded = explode("=",$contents); 

$accessToken = $exploded[1]; 
$score_URL = 'https://graph.facebook.com/' . $userFacebookID . '/scores'; 
$score_result = https_post($score_URL, 
    'score=' . $experience 
    . '&access_token=' . $accessToken 
); 

https_post功能如下:

function https_post($uri, $postdata) 
{ 
    $ch = curl_init($uri); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
    $result = curl_exec($ch); 
    curl_close($ch); 

    return $result; 
} 

你获得的Facebook用户ID后,您可以把这个在你的index.php和他们的得分将每次来比赛时间发送。

希望有所帮助。

+0

感谢您的重播 – Chandu

+0

不客气。 –