我想把这个linux命令控制台转换成PHP代码,通过curl发送数据,
curl -X POST -d 'data[][street]=1' link.....
谢谢!!
在EasyPHP上激活curl
未定义的对libcurl函数的引用
PHP CURL超时但CLI CURL起作用
使用s_client访问带有客户端证书但不curl的服务器?
$fields = 2; $fields_as_string = "key=value&key2=value" //open the curl connection $ch = curl_init(); //set the url,number of POST vars,POST data curl_setopt($ch,CURLOPT_URL,$url); // set the number of post fields curl_setopt($ch,CURLOPT_POST,$fields); // set the fields curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_as_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch);
不要忘了确保你已经启用了curl PHP扩展。
你可以使用PHP的cURL库。
<?PHP //initializing the connection. $connection = curl_init(); curl_setopt($connection,"http://www.yoursite.com"); curl_setopt($connection,1); curl_setopt($connection,http_build_query(array('postvar1' => 'value1'))); // receive server response ... curl_setopt($connection,CURLOPT_RETURNTRANSFER,true); $server_output = curl_exec ($connection); curl_close ($connection); ?>
你有没有试过PHP cURL库? ;)
https://PHP.net/curl
PHP文档总是给出很好的例子。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。