我正在为移动网络服务使用moodle rest插件,并且在本教程中,当我尝试测试网络服务时,我已经根据文档启用了rest API和其他相关服务,然后出现以下错误
{"exception":"moodle_exception","errorcode":"noauthheader","message":"No Authorization header found in request sent to Moodle"}
我有交叉检查moodle令牌甚至尝试新令牌但没有运气
这是我测试 php 代码来检查网络服务:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "mydomain.com/webservice/restful/server.php/core_course_get_courses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"options": {"ids":[2]}}',
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: {4838e6771cdbfd1eefbf37b3839587d9}",
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
请让我知道,我做错了什么
谢谢