【发布时间】:2015-03-24 07:07:59
【问题描述】:
我已经编写了一个 API,用于使用 PUT 方法更新用户信息,这里是 cURL 代码:
$postData = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
//curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
这里的 $data 是关联数组(key=>value 对)。在 API 端完成请求后。我收到的回复是:
11{"Status":200,"Response":"Success","ResponseData":"用户信息更新成功"}
在这里,在响应中。我无法弄清楚为什么整数值 11 会出现。请务必提供原因和解决方法。
提前致谢, 斯里尼瓦苏....
【问题讨论】:
-
如果 API 代码是您的,据我了解,那么它很可能是您的代码中被遗忘的
echo语句。编辑:看起来@a-p 先到了那里;)