这适用于GoInstant,我似乎无法将其转换为PHP cURL请求.
curl -X PUT \
-H 'Authorization: Bearer $ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{ "value": { "type": "hot dog", "topping": "mustard" }, "options": { "expire": 15, "cascade": "relish" } }' \
https://api.goinstant.net/v1/keys/1/1/food/1
这就是我所拥有的:
<?PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.goinstant.net/v1/keys/1/1/food/1");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('value' => array('foo' => 'hello!'))));
$stuff = curl_exec($ch, true);
echo $stuff;
curl_close($ch);
?>
解决方法:
由于请求必须是PUT请求,请删除
curl_setopt($ch, CURLOPT_POST, true);
并使用
curl_setopt($ch, CURLOPT_CUSTomrEQUEST, "PUT");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。