php - 解析错误:第 28 行 C:\xampp\htdocs\php\order\instagramapi.php 中的语法错误、意外的 ':'、期待 ',' 或 ')'
问题描述
为什么我在以下代码中出现上述错误,是语法不正确,我正在使用 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);
}
解决方案
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);
}
选项和价值不需要在那里。它就像文档中的占位符。文件是指职位。它是一个函数,因此您需要知道将哪些值传递给此函数才能工作,最重要的是按什么顺序。
推荐阅读
- python - 运行 PyInstaller 创建的可执行文件时出错
- mysql - 将多列内部连接到一个 ID
- konvajs - konvajs中的`destroy`和`remove`有什么区别
- kotlin - 如何在@ParametrizedTest 上应用条件参数?
- apache-spark - Apache Spark 中的多类分类错误指标
- mfc - 在 CDialogEX 项目中使用 CMFCStatusBar
- php - Niginx 下载 PHP 文件而不是执行 index.php
- php - Docker nginx 和 php-fpm
- android - 清单中存在时未授予运行时权限(Android)
- node.js - 如何在 cpanel 中运行节点应用程序以及设置 .htaccess 文件所需的内容