Same as the title; Use PHP's curl to send a post request; the data can be obtained, but there is an extra number 1 in the json string returned by the server. I checked the code and couldn't find when it was Added, Baidu can't find any information on this aspect at all, it should only be encountered by novices like me;
<?php
$url = "Domain name:9789/interface";
$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;
Page output:
{"model":{"id":1},"onTop":2,"soldCount":0,"result":0,"timeMillis":1492765168804}1< /code>
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