How do I post and delete scores in a Facebook app?
<p>I have read and tried to implement the scores system on the Facebook API almost word for word but am getting and getting an error </p>

<blockquote>
  <p>{"error":{"message":"Unsupported post
  request.","type":"GraphMethodException"}}</p>
</blockquote>

<p>So far no one has answered the solution to this problem, maybe I am doing some thing wrong. I am now re wording the question as to how other have managed to do it with code examples.</p>

<p>I would like to thank you in advance for you efforts in helping me.</p>

<p>The index.php has the following</p>

<pre><code>require_once 'facebook.php';

$fbAppId = 'APPID';
$fbSecret = 'FBSECRET';
$fbCanvasUrl = 'CANVASURL';

 // Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId'  =&gt; $fbAppId,
'secret' =&gt; $fbSecret,
));

// Get User ID
$user = $facebook-&gt;getUser();

// Redirect to the canvas url if we're authorized and logged in
// You can also use $_REQUEST['signed_request'] for this
if($_GET['code']) {
echo "&lt;script&gt;top.location.href='".$fbCanvasUrl."'&lt;/script&gt;";
exit;
}

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook-&gt;api('/me');
} catch (FacebookApiException $e) {
 error_log($e);
  $user = null;
 }
 }
 else {
 $loginUrl = $facebook-&gt;getLoginUrl();
  echo "&lt;script&gt;top.location.href='".$loginUrl."'&lt;/script&gt;";
 exit;
  }
</code></pre>

<p>It also includes the javascript</p>

<pre><code>        &lt;script type="text/javascript"&gt;
    window.fbAsyncInit = function() {
        FB.init({appId: '&lt;?=$fbAppId?&gt;', status: true, cookie: true, xfbml: true,oauth: true});
    };
    (function() {
        var ts = new Date().getTime();
        var e = document.createElement("script");
        e.type = "text/javascript";
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js?ts='+ts;
        e.async = true;
        document.getElementById("fb-root").appendChild(e);
    }());
        &lt;/script&gt;
</code></pre>

<p>So.... The index.php initiates everything, I have a Javascript file that will play the game and set a cookie with the score and the following php file picks up the cookie and sets the score....</p>

<pre><code>    &lt;?php
require_once('facebook.php');

$config = array(
    'appId' =&gt; 'APPID',
    'secret' =&gt; 'SECRET',
  );

  $facebook = new Facebook($config);


  $app_id = 'APPID';
  $app_secret = 'SECRET';
  $canvas_page_url = 'CANVASURL';

// Get the User ID
  $signed_request = parse_signed_request($_POST['signed_request'],
    $app_secret);

    $uid = $signed_request['user_id'];


  // Get an App Access Token
  $token_url = 'https://graph.facebook.com/oauth/access_token?'
    . 'client_id=' . $app_id
    . '&amp;client_secret=' . $app_secret
    . '&amp;grant_type=client_credentials';

  $token_response = file_get_contents($token_url);
  $params = null;
  parse_str($token_response, $params);
  $app_access_token = $params['access_token'];


  //Get Score **************
  if(isset($_COOKIE['Sscore']))
        $cscore = $_COOKIE['Sscore'];
else
        exit;


$score=$cscore;
  // POST a user score
  //print('Publish a User Score&lt;br/&gt;');
  $score_URL = 'https://graph.facebook.com/' . $uid . '/scores';
  $score_result = https_post($score_URL,
    'score=' . $score
    . '&amp;access_token=' . $app_access_token
  );
 printf('&lt;br/&gt;%s&lt;br/&gt;',$score_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;
  }
  function parse_signed_request($signed_request, $secret) {
    list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

    // decode the data
    $sig = base64_url_decode($encoded_sig);
    $data = json_decode(base64_url_decode($payload), true);

    if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
      error_log('Unknown algorithm. Expected HMAC-SHA256');
      return null;
    }

    // check sig
    $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
    if ($sig !== $expected_sig) {
      error_log('Bad Signed JSON signature!');
      return null;
    }

    return $data;
  }

  function base64_url_decode($input) {
    return base64_decode(strtr($input, '-_', '+/'));

  } 


?&gt;
</code></pre>
