这是针对GoInstant的,我似乎无法将它转换为PHP请求。
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);
?> 发布于 2013-11-11 06:38:26
由于请求必须是PUT请求,所以请删除
curl_setopt($ch, CURLOPT_POST, true); 并使用
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");https://stackoverflow.com/questions/19900149
复制相似问题