有人能告诉我如何使用HTTP POST进行php卷曲吗
我想发送如下数据:
用户名=user1,密码=passuser1,性别=1
至www.domain.com
我希望curl返回类似result=OK的响应。有什么例子吗
<;?php
//
//一个非常简单的PHP示例,用于向远程站点发送HTTP POST
//
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,”http://www.example.com/tester.phtml");
卷曲设置($ch,卷曲设置桩,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,
“postvar1=value1&;postvar2=value2&;postvar3=value3”);
//在现实生活中,您应该使用以下内容:
//curl_setopt($ch,CURLOPT_POSTFIELDS,
//http_build_查询(数组('postvar1'=>;'value1'));
//接收服务器响应。。。
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$server\u output=curl\u exec($ch);
卷曲关闭($ch);
//进一步处理。。。
如果($server_output==“OK”){…}其他{…}
?>;