我試圖做一個頁面的帖子,所以不必完成表單,但似乎無法得到它的工作。從頁面表單獲取POST URL,我錯過了什麼?
形式是在這裏:
http://www.tuffnells.co.uk/proof-of-delivery
我想要做的事:
echo file_get_contents("http://www.tuffnells.co.uk/proof-of-delivery?ctl00_maincontent_ctl02_btnDoPODLookup=true&ctl00$maincontent$ctl02$tbAccountRef=01484267&ctl00$maincontent$ctl02$tbConsignmentRef=2837&ctl00$maincontent$ctl02$tbDestPostcode=AL15BY");
ctl00 $ $搜索Maincontent $ ctl02 = tbAccountRef 01484267 ctl00 $ $搜索Maincontent $ ctl02 tbConsignmentRef = 2837 ctl00 $ maincontent $ ctl02 $ tbDestPostcode = AL15BY
這些是我通過的3個,但也許我錯過了URL中的其他內容,這就是爲什麼它不工作,我不確定是否有人可以從表單中看到我可能會丟失的東西。
**,捲曲修訂版**
<base href="http://www.tuffnells.co.uk"/>
<?php
if (isset($_GET['orderid'])){
$url = 'http://www.tuffnells.co.uk/PODLookupResults.aspx?__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATEGUID=7ca82b1d-b722-4cdc-b74a-b338d8577ffa&__VIEWSTATE=&__EVENTVALIDATION=%2FwEdAAevVXD1oYELeveMr0vHCmYPaomE%2FDwQD43eOdzEj3p%2Fm4U4pgxq6tlupSJfQZQBazFFj%2F1LmlGLyHFagz1yHZm8bjowVgAJ8C3e%2B2bVMPt91KjXCHjnAsonQDi2zFSuasUVzpitHiLDCDtiLHCjNCQG4CxrbV5VPFqBeOgs2X52AD%2FEb%2BYR%2BEJ68PaN2CiyKzE%3D&ctl00%24ctl16%24tbHeaderSearch=Search..&ctl00%24maincontent%24tbAccountRef=01484267&ctl00%24maincontent%24btnDoPODLookup=Search+Again';
$fields = array(
'ctl00%24maincontent%24tbConsignmentRef' => urlencode($_POST['orderid']),
'ctl00%24maincontent%24tbDestPostcode' => urlencode($_GET['postcode'])
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
?>
http://ambientlounge.com/external/ukTracking.php?orderid=2837&postcode=AL15BY
'的file_get_contents()'不* *後什麼。你需要看看cURL之類的東西。 –
好吧,新的PHP所以不知道如何,但如果你去這裏:http://www.tuffnells.co.uk/proof-of-delivery?ctl00_maincontent_ctl02_btnDoPODLookup=true & ctl00 $ maincontent $ ctl02 $ tbAccountRef = 01484267 & ctl00 $ maincontent $ ctl02 $ tbConsignmentRef = 2837 & ctl00 $ maincontent $ ctl02 $ tbDestPostcode = AL15BY它不起作用...所以猜想需要找出正確的url來發布? – James
URL不接受查詢字符串,所以添加查詢字符串將永遠不會工作。你必須學習像[cURL](http://php.net/manual/en/book.curl.php) –