从页面表单获取POST URL,我缺少什么?

时间:2016-02-23 13:38:25

标签: php

我正在尝试对网页发帖,所以不必填写表单,但似乎无法使其正常工作。

表格在这里:

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中的其他内容,这就是为什么它无法正常工作,我不确定是否有人可以从表单中看到我可能缺少的内容。

** CURL **更新

<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

1 个答案:

答案 0 :(得分:0)

你需要使用curl来发布这样的帖子。 例如:

$curl = curl_init();
        $options =  array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'http://www.tuffnells.co.uk/proof-of-d...');//etc
        curl_setopt_array($curl,$options);
        echo $options[CURLOPT_URL]; //will print you all the path- just for testing.
        curl_exec($curl);
        curl_close($curl);
希望它有所帮助...