405错误php get请求

405错误php get请求,php,get,http-status-code-405,Php,Get,Http Status Code 405,我有这个脚本,我想请求一个页面,但它给了我405帮助。这是我的密码: $result = "SOMETHING" $kahootId = '0c17fb60-76c6-424c-9326-d1154cbc70d3'; $pageUrl = 'https://create.kahoot.it/rest/kahoots/' . $kahootId; $quizheader = array(); $quizheader[] = 'content-type: application/json'; $q

我有这个脚本,我想请求一个页面,但它给了我405帮助。这是我的密码:

$result = "SOMETHING"
$kahootId = '0c17fb60-76c6-424c-9326-d1154cbc70d3';
$pageUrl = 'https://create.kahoot.it/rest/kahoots/' . $kahootId;
$quizheader = array(); 
$quizheader[] = 'content-type: application/json';
$quizheader[] = 'authorization: ' . $result;

curl_setopt($ch, CURLOPT_URL, $pageUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 
curl_setopt($ch, CURLOPT_HEADER,$quizheader);

$store2 = curl_exec($ch);
print_r($store2);
curl_close($ch);
此代码返回:

HTTP/1.1 405 Method Not Allowed
Server: openresty/1.11.2.2
Date: Tue, 11 Jul 2017 20:53:03 GMT
Content-Type: application/json
Content-Length: 150
Connection: keep-alive

{"error":"javax.ws.rs.WebApplicationException","exception":"javax.ws.rs.WebApplicationException","timestamp":1499806383136,"duration":0,"errorCode":0} 
此代码基于此python脚本:

如果您只需要一个带有自定义标题的GET请求,而不需要正文,那么您可以使用以下甚至不需要Curl的方法:

$token = "SOMETHING"
$kahootId = '0c17fb60-76c6-424c-9326-d1154cbc70d3';
$url = 'https://create.kahoot.it/rest/kahoots/'.$kahootId;

$options = array(
    'http' => array(
        'method'  => 'GET',
        'header'  => "Authorization: ".$token."\r\n"
    )
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

你查过了吗?@user2464424问题是,我没有数据要发送!哦,我需要一个get请求。您是否也尝试过不传递
内容类型:application/json
头?查看输出响应似乎是api服务器上的错误,而不是您这边的错误,或者您没有发出正确的请求,在这种情况下,请阅读api文档