我有一個表單。使用cURL我得到這個迴應:cURL獲取值並傳遞到下一頁並獲得結果
<form id="Homepage" action="/WebApp/home.htm" method="post">
<div id="searchElements">
<input id="imeiNumber" type="hidden" name="imeiNumber" value=""/>
<input type="hidden" name="tokenEncrypted" id="tokenEncrypted" value="GQ5SA0FDIHDH6WWNR1TC3UVVUIEBFNMVYDDL7UCX9A"/>
<input type="hidden" name="tokenTimeStamp" id="tokenTimeStamp" value="1448839083432"/>
</form>
這裏我需要通過值imeiNumber
得到我的結果。
我是否需要臨時保存tokenEncrypted
和tokenTimeStamp
,並使用cURL將它們與imeiNumber一起傳遞?
這裏是我的代碼,以獲得上述結果:
<?php
$cook = "/cookie/gsx.txt";
$site = "www.mywebsite.com";
$data = "imeiNumber=357996051632600";
$curl = curl_init('https://'.$site.'/WebApp/home.htm');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Connection: keep-alive',
'Accept: application/json, text/javascript, */*; q=0.01',
'Origin: https://'.$site,
'X-Requested-With: XMLHttpRequest',
'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B350 Safari/8536.25',
'Referer: https://'.$site.'/WebApp/resource.htm',
) );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cook);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
echo $der1 = curl_exec($curl);
curl_close($curl);
?>
我如何保存這個值,並通過他們在我的要求?
我想說的答案是肯定的 – RamRaider
@RamRaider請你展示如何做,在你的答案的樣本? – Cyborg