2012-08-15 69 views

回答

0

像错误消息指出,确保您使用的Application Access Token

如果你只是使用图形API资源管理器,你可能有一个用户访问令牌为您的帐户

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);