如题;使用php的curl发送post请求;数据可以拿到,但是在服务端返回的json字符串上多了一个数字1,查代码也没找到是什么时候被添加上的,百度完全找不到这方面的资料,应该只有我这样的新手才会遇到吧;
<?php
$url = "域名:9789/接口";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "goodsId=56");
$rt = curl_exec($ch);
curl_close($ch);
echo $rt;
页面输出:
{"model":{"id":1},"onTop":2,"soldCount":0,"result":0,"timeMillis":1492765168804}1
Add this
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Search for the specific meaning by yourself
This 1 should be returned by your interface. You should look at where your 9789 interface is.
$rt == 1