php - Can't publish a high score to player's timeline on Facebook -
i'm developing php game , post players highscores own facebook wall /timeline.
i've set facebook app , php code i'm using post score (as provided facebook itself):
<?php require 'facebook-sdk/facebook.php'; $app_id = my_app_id; $app_secret = my_app_secret; $score = 1500; // gonna passed someway... $facebook = new facebook(array( 'appid' => $app_id, 'secret' => $app_secret, )); $user = my_user_id; // replaced call $facebook->getuser() $app_access_token = get_app_access_token($app_id, $app_secret); $facebook->setaccesstoken($app_access_token); $response = $facebook->api('/' . $user . '/scores', 'post', array( 'score' => $score, )); print($response); // helper function app access token function get_app_access_token($app_id, $app_secret) { $token_url = 'https://graph.facebook.com/oauth/access_token?' . 'client_id=' . $app_id . '&client_secret=' . $app_secret . '&grant_type=client_credentials'; $token_response =file_get_contents($token_url); $params = null; parse_str($token_response, $params); return $params['access_token']; } ?> of course there login , install section have omitted, asking user login , grant 'publish_stream' , 'publish_actions' privileges app.
this working success, response variable outputs 1. can see posted score using facebook graph api explorer assume working fine , smooth.
the problem not able see supposedly posted user-story anywhere on facebook. reading documentation seems me user story has automatically published when 1 saves score. example, have here or here.
does solved problem already? see might have missing? can please point me @ right direction solve issue?
any highly appreciated.
you write
reading documentation seems me user story has automatically published when 1 saves score.
scores not automatically published. published under conditions, namely when user:
- gets new high score ("high score story").
- pass friend's score("passing story").
in code post score 1,500 everytime. after first time post it, when post again repeatedly testing, post request successful score not published again since not new high.
sources:
facebook developers: games tutorial.
facebook developers developer blog: games update: expanding distribution scores , achievements
Comments
Post a Comment