0

I want get data from this website: https://vrl.lta.gov.sg/lta/vrl/action/pubfunc?ID=EnquireTransferFee

This is my code using CURL:

function postPage($url, $pvars, $referer, $timeout){
    if(!isset($timeout))
        $timeout=30;
    $curl = curl_init();
    $post = http_build_query($pvars);
    if(isset($referer)){
        curl_setopt ($curl, CURLOPT_REFERER, $referer);
    }
    curl_setopt ($curl, CURLOPT_URL, $url);
    curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
    curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
    curl_setopt ($curl, CURLOPT_HEADER, 0);
    curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt ($curl, CURLOPT_POST, 1);
    curl_setopt ($curl, CURLOPT_POSTFIELDS, $post);
    curl_setopt ($curl, CURLOPT_HTTPHEADER,
        array("Content-type: application/x-www-form-urlencoded"));
    $html = curl_exec ($curl);
    curl_close ($curl);
    return $html;
}
$vars = array(
    'vehicleNo'    => 'SFT4228H',
    'transferDate' => '10042014'
);

$result = postPage('test.php', $vars, 'https://vrl.lta.gov.sg/lta/vrl/action/pubfunc?ID=EnquireTransferFee', '30');

print "Result:".$result; //Show data in my website 

=> How to get this data

1 Answer 1

0

As you have it here, it appears that you are using curl to request "test.php".

Try switching them around in your function call:

$result = postPage('https://vrl.lta.gov.sg/lta/vrl/action/pubfunc?ID=EnquireTransferFee', $vars, 'test.php', '30');
1
  • When I post the data in $vars to this page using a regular old HTML form, I see a page with the form on it. The URL you're trying to post data to doesn't do anything with the data. What are you trying to accomplish here?
    – MGM
    Apr 10, 2014 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.