我在 PHP 中进行 curl 以在站点上发布数据并回显结果,但它不发布数据这是我的代码:
<?php
$imei = "imei=XXXXXXXXX";
//set POST variables
$url = 'http://XXX.com/XXX.php';
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $imei);
curl_setopt ($ch, CURLOPT_REFERER, 'http://www.XXX.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w+'));
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo $result;
echo $imei;
?>
当我回显 $imei 时,它会显示完整的字符串但未传递数据:S
请帮忙,代码有什么问题?
提前致谢
更新:在网站的原始 html 中,它是 name="imei" 而不是 id="imei"