我一直在寻找外部网站上的自动化工作。我被告知我应该使用curl,所以我想我问的是卷曲是一种选择吗?我将如何使用这些输入字段执行此操作:
name="fname"
name="lname"
name="bio"
name="website"
name="email"
name="password"
name="Cpassword"
name="token"
name="submit"
答案 0 :(得分:1)
是的,在cron作业示例中使用curl set正确地告诉你。
//The data
$data = array(
"fname" => "Mark",
"lname" => "Jones",
"Bio" => "Hi i like rose's because they smell nice",
"website" => "http://mysite.com",
"email" => "mark@mysite.com",
"password" => "mypassword",
"token" => "your token",
"Agent" => "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5"
);
//External site direct link
$external_site = "http://external-site.com";
//Input field names with data ready
$input_fields = "fname=".$data['fname']."&lname=".$data['lname']."&Bio=".$data['bio']."&website=".$data['website']."&email=".$data['email']."&password=".$data['password']."&Cpassword=".$data['password']."&token=".$data['token']."&submit=";
//Do the curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL , $external_site);
curl_setopt($ch, CURLOPT_USERAGENT, $data['Agent']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$done = curl_exec ($ch);
curl_close($ch);
有关curl的更多信息,请访问http://php.net/manual/en/book.curl.php,对于cron job,大多数主机提供了一个现成的cron功能来使用XD。