0
我正在爲正在製作的遊戲設置成就。 Flash會發送命令來解鎖成就,以及成就的url。在我的服務器上,我擁有將顯示順序和成就網址從Flash傳遞到Facebook的代碼。當我按下按鈕解鎖Flash中的成就時,它在我的遊戲中成功解鎖,我可以在代碼中看到它。當我點擊iFrame中的按鈕解鎖成就時,它不會解鎖。記錄$結果將返回1,但它不會顯示在股票行情或計數爲解鎖。從Flash設置Facebook成就
postachievement.php
<?php
include 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '[APP_ID]',
'secret' => '[APP_SECRET]',));
$access_token = $facebook->getAccessToken();
//$uid = $facebook->getUser();
$uid = "[Static ID for Testing]";
$achievement = $_POST['achievement'];
$achievement_URL = 'https://graph.facebook.com/' . $uid . '/achievements';
$achievement_result = https_post($achievement_URL,
'achievement=' . $achievement
. '&access_token=' . $access_token);
error_log($result);
function https_post($uri, $postdata)
{
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
Achievements.as
package Facebook
{
public class Achievements
{
public static var trophy:Achievements;
private static var achievement:String; // URL of the Achievement
public function Achievements()
{
trophy = this;
}
public static function testAchievement1():void
{
achievement = "https://(URL)/zombies/game/achievements/test6.html";
Database.data.giveAchievement(achievement);
}
public static function testAchievement2():void
{
achievement = "https://(URL)/zombies/game/achievements/test7.html";
Database.data.giveAchievement(achievement);
}
public static function testAchievement3():void
{
achievement = "https://(URL)/zombies/game/achievements/test8.html";
Database.data.giveAchievement(achievement);
}
public static function testAchievement4():void
{
achievement = "https://(URL)/zombies/game/achievements/test9.html";
Database.data.giveAchievement(achievement);
}
public static function testAchievement5():void
{
achievement = "https://(URL)/zombies/game/achievements/test10.html";
Database.data.giveAchievement(achievement);
}
}
}
從數據庫類的一些片段,與成績處理。
Database.as
// Give Achievement
private static var achieveLoader:URLLoader = new URLLoader();
private static var achieveRequest:URLRequest = new URLRequest;
achieveRequest.url = "https://(URL)/zombies/game/postachievement.php";
// Grant Player an Achievement
public function giveAchievement(_achievement:String):void
{
var vars:URLVariables = new URLVariables();
vars.achievement = _achievement;
achieveRequest.method = URLRequestMethod.POST;
achieveRequest.data = vars;
achieveLoader = new URLLoader();
achieveLoader.dataFormat = URLLoaderDataFormat.TEXT;
achieveLoader.load(achieveRequest);
}