为什么在以下代码中出现上述错误,语法不正确,我正在使用Instagram进行授权。
public function getAccessTokeAndUserDetails($code){
$postFields = array(
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'grant_type' => "authorization_code",
'redirect_uri' => $this->redirectURI,
'code' => $code
);
$ch = curl_init();
curl_setopt($ch, option:CURLOPT_URL,value:"https://api.instagram.com/oauth/access_token");//line 28
curl_setopt($ch, option:CURLOPT_RETURNTRANSFER, value:1);
curl_setopt($ch, option:CURLOPT_SSL_VERIFYHOST, value:0);
curl_setopt($ch, option:CURLOPT_SSL_VERIFYPEER, value:0);
curl_setopt($ch, option:CURLOPT_POST, value:1);
curl_setopt($ch, option:CURLOPT_POSTFIELDS, $postFields);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response,assoc:true);
}
答案 0 :(得分:0)
public function getAccessTokeAndUserDetails($code){
$postFields = array(
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'grant_type' => "authorization_code",
'redirect_uri' => $this->redirectURI,
'code' => $code
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.instagram.com/oauth/access_token");//line 28
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response,assoc:true);
}
选项和值不需要存在。就像文档中的占位符一样。文档指的是职位。这是一个函数,因此您需要知道传递给该函数的值才能起作用,并且最重要的是按哪个顺序。