开发者

Having Difficulty Using cURL and PHP to Login and Download

Here is the code that I am using to try and accomplish this:

<?php
$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, 'linkToLoginPage.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email=email@example.com,password=password');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, 'link开发者_JAVA技巧ToDownloadFile.pdf');
$content = curl_exec ($ch);
curl_close ($ch); 

?>

I set it up with my information, but it just produces a blank page. I think my main issue is with the CURLOPT_POSTFIELDS. Here is the link to the page I am trying to login.

I looked at the source code but I cannot find a clear definition of the form values. Any ideas?


Try

curl_setopt($ch, 
            CURLOPT_POSTFIELDS, 
            'email=email@example.com&password=password' );

(& not ,)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜