用curl php发送帖子

时间:2012-07-18 01:11:12

标签: php http post curl request

我试图在网页上发送一些身份验证参数,这是代码

$url = "http://www.webpage.com/account/submit";
$handler = curl_init();
curl_setopt($handler, CURLOPT_URL, $url);
curl_setopt($handler, CURLOPT_POST,true);
curl_setopt($handler, CURLOPT_POSTFIELDS, "username=user@webmail.com&remember=true&password=123456");
$response = curl_exec ($handler);
curl_close($handler);

当我运行此脚本时,我没有显示任何内容,我试图成功地将我变成一个没有HTML表单的网站。 。 。有另一种方法可以做到这一点???

1 个答案:

答案 0 :(得分:0)

当然它没有显示任何内容。你至少需要echo一些东西(可能会对$response做一些事情来实际检查登录结果)。另外,请确保已启用error reporting