I spent a lot of time trying to register an achievement with facebook using grahp API, but I am always getting this :
{"error":{"type":"OAuthException","message":"(#2) Object at achievement URL is not of type game.achievement"}}
The code is :
$achievementUrl = 'http://www.dappergames.com/test.html';
$url = 'https://graph.facebook.com/' . $appID . '/achievements?achievement=' .
$achievementUrl . '&display_order=' . $order . '&access_token=' . $accessToken . '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$data = curl_exec($ch);
print_r($data);
Any help will be greatly appreciated.
Thanks
Looking at your test, you're missing the most important tag, og:url.
Facebook uses that tag to find the location of where to parse the information, I was having a similar problem on adding achievements to my app until I figured that out. Here's how mine looks. Mine passes the debugger and works currently on Facebook.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Game Loader</title>
<meta property="og:type" content="game.achievement"/>
<meta property="og:title" content="Game Loader"/>
<meta property="og:url" content="FULL LINK TO THIS PAGE"/>
<meta property="og:description" content="You loaded the gam!e"/>
<meta property="og:image" content="Link to 50x50 image"/>
<meta property="og:points" content="10"/>
<meta property="fb:app_id" content="YOUR_APP_ID"/>
</head>
<body>
</body>
</html>
After updating your HTML to this, run it through the debugger linked above so that it is updated on Facebook's end (and to see if you receive any warnings) and then create it and give it to users.
Here's how I created it:
curl -D "achievement=[URL TO ACHIEVEMENT]&access_token=[APPLICATION ACCESS TOKEN]" https://graph.facebook.com/APP_ID/achievements
and I then rewarded it to users using the Facebook Javascript API on my canvas application like so:
FB.api('/'+user_id+'/achievements', 'POST', { 'access_token': [APPLICATION ACCESS TOKEN], 'achievement':[FULL URL]},
function(response) {
if(console)
console.log(response);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With