我正在使用以下代码自动填写字段并在另一台服务器上提交表单:
<?php
include "Snoopy.class.php";
$snoopy = new Snoopy;
$snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1";
$snoopy->referer = "http://www.google.com/";
$url = "http://example.com/?page=a";
$data["field_name"] = "value";
$snoopy->httpmethod = "POST";
$snoopy->submit($url, $data);
echo $snoopy->results;
?>
问题是它不起作用!
页面http://example.com/?page=a的来源是:
<form action="" method="post" class="horizontal-form" role="form" >
<input type="hidden" name="submit_form" value="true" />
<input type="text" name="field_name" class="form-control" value="" >
<button type="submit" class="btn"><i class="icon-ok"></i> Send</button>
</form>
知道如何解决吗?会不会是主页中的“动作”是空的?
谢谢您的帮助。