我在使用cURL特定頁面時遇到問題。cURL帖子無法運行PHP
一個活生生的代碼工作:http://svgen.com/jupiter.php
這裏是我的代碼:
$url = 'https://uspdigital.usp.br/jupiterweb/autenticar';
$data = array('codpes' => 'someLogin', 'senusu' => 'somePass', 'Submit' => '1');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, "FileHere");
curl_setopt($ch, CURLOPT_COOKIEFILE, "FileHere");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
curl_exec($ch);
curl_close($ch);
雖然我用了相同的URL和POST數據,的file_get_contents工作:
$options = array('http' => array('method' => 'POST','content' => http_build_query($data)));
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
有人可以幫助我? 謝謝。
你得到什麼錯誤? – 2013-03-01 06:21:32
你有沒有得到任何回報? – uvinod 2013-03-01 06:21:40
我無法使用cURL進行身份驗證 – 2013-03-01 06:21:51