我想通过跑步获得 Facebook 封面
curl https://graph.facebook.com/me/?fields=cover?access_token=*****
在我的终端中 - 我不断得到
必须使用活动访问令牌来查询有关当前用户的信息。
这是我的代码:
public function feed(){
$id = Auth::user()->account_id;
$token_oauth = DB::table('tokens')->where('account_id','=',$id)->first();
$token = $token_oauth->oauth;
$url = 'https://graph.facebook.com/me/feed?access_token='.$token;
$data = shell_exec('curl '.$url);
$raw = json_decode($data,true);
return $raw;
}
它有效。它返回提要列表。然后我按照相同的步骤制作封面照片。
public function cover(){
$id = Auth::user()->account_id;
$token_oauth = DB::table('tokens')->where('account_id','=',$id)->first();
$token = $token_oauth->oauth;
$url = 'https://graph.facebook.com/me?fields=cover&access_token='.$token;
$data = shell_exec('curl '.$url);
$raw = json_decode($data,true);
return $raw;
}
它回来了
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500,"fbtrace_id":"AOkTdE\/rYNW"}}
这是正确的,访问令牌有效,但您写了“?”而不是第二个参数的“&”:
https://graph.facebook.com/me/?fields=cover&access_token=*****
顺便说一句,您可以在调试器中检查您的令牌是否有效:https://developers.facebook.com/tools/debug/