我试图将用户分数(整数值)发布到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.我做错了吗?