2011-10-13 77 views
1

我正在尝试将用户得分(整数值)发布到facebook分数。我的代码如下:从facebook游戏应用程序发布用户得分

<pre><?php getScores($accessToken) ?></pre> 
<pre><?php postScores($accessToken, 'PLAYER_ID', 34) ?></pre> 
<pre><?php getScores($accessToken) ?></pre> 

和PHP代码:

<?php 
function getScores($accessToken) { 
    $fbCurl = curl_init(); 
    curl_setopt($fbCurl, CURLOPT_URL, 'https://graph.facebook.com/APPLICATION_ID/scores&access_token=' . $accessToken); 
    curl_setopt($fbCurl, CURLOPT_RETURNTRANSFER, 1); 
    $scores = curl_exec($fbCurl); 
    curl_close($fbCurl); 
    echo '<h1>Scores</h1><pre>'; 
    var_dump(json_decode($scores)); 
    echo '</pre>'; 
} 

function postScores($accessToken, $uid = 'PLAYER_ID', $score = 23) { 
    $fbCurl = curl_init(); 
    curl_setopt($fbCurl, CURLOPT_URL, sprintf('https://graph.facebook.com/%s/scores&access_token=' . $accessToken, $uid, $score)); 
    curl_setopt($fbCurl, CURLOPT_RETURNTRANSFER, 0); 
    $data = array('score' => $score); 
    curl_setopt($fbCurl, CURLOPT_POST, true); 
curl_setopt($fbCurl, CURLOPT_POSTFIELDS, $data); 
    curl_exec($fbCurl); 
    curl_close($fbCurl); 
} 

发布后,得分为这个用户的价值仍然是0。我做错什么了吗?

回答

相关问题