我是新来curl
。只是我尝试使用curl
脚本发布价值,但我得到空的答复。帮助我在我的代码中有任何错误?如何使用curl
卷曲脚本 - POST
$params = array('name' => 'karthick', 'type' => 'data');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/test.php?action=create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// curl_setopt($ch, CURLOPT_USERPWD,$authentication);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// curl_setopt($ch, CURLOPT_REFERER,'http://www.example.com.au');
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$result = curl_exec($ch);
curl_close($ch);
var_dump($result);
你得到200首先响应状态?建议详细的设置和你获取此URL正确的响应之前,喜欢用卷曲从命令提示符有一个可能性,它甚至可能是一个服务器端的问题? – optimusprime619
得到响应状态-201 :)现在的工作.Thanks您的宝贵意见 –