I'm trying to use curl to post to this site and I'm not even getting the page to come up.. the fields aren't as straight forward as having a name and a value and the form has an onsubmit. The address and action of the form also seem to change each time the page is reloaded and so the number following the "e" in the address increases by 1 each time..
$url = "http://www.canadapost.ca/cpotools/apps/track/personal/findByRefNumber?execution=e14s1"
$parms = array(
'tapByTrackSearch:refSearch:refNumbers' => $refnumber,
'tapByTrackSearch:refSearch:ref_submit_button' => '',
'tapByTrackSearch:refSearch_SUBMIT' => 1,
'javax.faces.ViewState' => 'v1Dxx9hSieZwMVPzZZHAPSkIfrSZM1jbO4mNTTN2U0GpxoAFjzFhwFOL94NDwf6uXDCuuM24L5YMuqNSqP+dRYKpGsqhkV+2Tm+y5O2kdGF/NCNJRzUyCzDzaoELlvqQ/L5LRDJEnbwOXh1YOjylrA==',
);
I loop the $parms array later and is passed as $new_fields string.
$res = curl_init();
$config =
array(
CURLOPT_URL => $this->url,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $new_fields,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE
);
curl_setopt_array($res,$config);
$result = curl_exec($res);
curl_close($res);
echo $result;
the output of new fields:
tapByTrackSearch:refSearch:refNumbers=#12484&tapByTrackSearch:refSearch:ref_submit_button=&tapByTrackSearch:refSearch_SUBMIT=1&javax.faces.ViewState=v1Dxx9hSieZwMVPzZZHAPSkIfrSZM1jbO4mNTTN2U0GpxoAFjzFhwFOL94NDwf6uXDCuuM24L5YMuqNSqP+dRYKpGsqhkV+2Tm+y5O2kdGF/NCNJRzUyCzDzaoELlvqQ/L5LRDJEnbwOXh1YOjylrA==&
My code has worked fine with other sites but for some reason I am either entering the fields and their values wrong or the url?