我有我的捲曲請求的問題。登錄與捲曲並與捲曲的其他請求之後
我想登錄,它的工作原理。我想保存cookie以保持連接可用,它工作。
$lien = 'https://thewebsite.com';
$postfields = array(
'username' => 'test123',
'password' => 'test123'
);
$path_cookie = 'connexion.txt';
if (!file_exists(realpath($path_cookie))) touch($path_cookie);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_COOKIEJAR, realpath($path_cookie));
$return = curl_exec($curl);
echo($return);
curl_close($curl);
第二部分:
$lien2 = 'https://thewebsite.com/myaccount';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien2);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_COOKIEFILE, realpath($path_cookie));
$return = curl_exec($curl);
echo realpath($path_cookie);
curl_close($curl);
但是,當我要做出其他要求,將無法正常工作,輸出:
對象移動到這裏。
這裏是登錄(https://thewebsite.com)的網頁...
所以聯接不留可用,並且服務器已被踢出當我嘗試實現第二curl命令。
任何人都可以幫助我嗎?
也許第一個請求是不完整的在第二個之前,我怎麼能做出2個請求之間的暫停? (睡眠將無法工作)
也許第一個請求執行第二時是不完整的...睡眠(10)將無法正常工作,使2之間的「暫停」,有許多人有一個想法? – Peter
或者,也許會不「開」當我嘗試第二請求...... – Peter