图谱API资源管理器:删除分数

时间:2012-08-15 22:38:36

标签: facebook-graph-api

我正在尝试从“Graph API Explorer”中删除所有“得分”。我选择了我的应用程序(在右上角),DELETE并写了https://graph.facebook.com/APP_ID_OMITTED/scores(作为请求),但我得到了错误:

{
  "error": {
    "message": "(#15) This method must be called with an app access_token.", 
    "type": "OAuthException", 
    "code": 15
  }
}

我哪里出错了?

2 个答案:

答案 0 :(得分:1)

现在正在运行,这是工作代码:

// Delete scores for all users
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'];
}

$app_id = 'OMITTED';
$app_secret = 'OMITTED';
$access_token = get_app_access_token($app_id, $app_secret);

$request_body = '';
$ch = curl_init('https://graph.facebook.com/'.$app_id.'/scores?access_token='.$access_token);
        //curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
        $response = curl_exec($ch);
var_dump($response);

答案 1 :(得分:0)

如错误消息所示,请确保您使用Application Access Token

如果您只使用Graph API资源管理器,则可能拥有帐户的用户访问令牌