首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Facebook flash游戏高分API

Facebook flash游戏高分API
EN

Stack Overflow用户
提问于 2012-08-31 15:22:19
回答 1查看 1.1K关注 0票数 1

由于我是facebook游戏的新手,是否有任何第三方API用于flash游戏。实际上,我使用的是mochi highscore API,但我不想通过mochi登录。通过facebook id直接提交。让我知道任何第三方API或建议任何教程。

致敬,chandu

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-31 21:34:03

在Facebook中将分数发布到高分是相当容易的,请查看以下代码。所有你需要的是当你登录用户时从facebook获得的userID,以及你在游戏中使用的分数,比如经验,积分或其他东西。

代码语言:javascript
复制
// 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函数如下所示:

代码语言:javascript
复制
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;
}

你可以在获得脸书用户ID后把它放到你的index.php中,每次他们来看比赛时他们的分数都会被发送出去。

希望这能有所帮助。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12210653

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档