使用multipart / form-data和边界php的卷曲帖子

时间:2018-05-18 06:06:19

标签: php curl login web-scraping

我想使用curl从其他网站创建登录,但是在创建过程中遇到了麻烦。

我使用的脚本如下:

$post_login_client = array("account_number" => 1234123, "pin" => 123123, "submit"=>"");
$headers = array("Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryijPWqniP0zu0m47e"); 
$fp = fopen("cookie-website.txt", "w");
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie-website.txt");
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie-website.txt");
curl_setopt($login, CURLOPT_TIMEOUT, 40);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_URL, "https://secure.website.com/client/login");
curl_setopt($login, CURLOPT_HTTPHEADER,$headers);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, $postfields);
return curl_exec ($login);
curl_close ($login);

0 个答案:

没有答案