Problems with a CURL

1

Thanks for responding, change as you indicate and nothing, why will it be?

$ track = '103494'; $ url = ' link ';

$ fields = array (   'ID' = > $ track,   'Go' = > one,   'Type' = > 'T' );

$ fields_string = http_build_query ($ fields);

$ handler = curl_init ($ url);

curl_setopt ($ handler, CURLOPT_URL, $ url); curl_setopt ($ handler, CURLOPT_POST, count ($ fields)); curl_setopt ($ handler, CURLOPT_POSTFIELDS, $ fields_string);

$ result = curl_exec ($ handler);

curl_close ($ handler);

echo $ response;

    
asked by Jose Doe 23.08.2016 в 05:51
source

2 answers

1

Reviewing the site, you lack parameters through which to do POST.

The form sends several hidden parameters that you are not sending:

<input type="hidden" name="Go" value="">
<input type="hidden" name="ID" value="">
<input type="hidden" name="Type" value="">
<input type="hidden" name="OpenWindowNoMenuSystemKey" value="">

in addition to processing through JS. Reviewing the headers with the element inspector and testing with bash curl, I got to the minimum data to work are ID=<tu tracking>| , Type=T and Go=1 .

IMPORTANT: must be set if or if a | (pipe) at the end of the tracking or if it does not, it does not work (see the escaped character %7C which is a | ).

$ curl -XPOST http://s5.stephytrackingonline.com/Cargonam/MainWebsite.asp -d "ID=104454%7C&Type=T&Go=1" | grep ENTREGADO

Return:

<font face="Verdana" size="1">ENTREGADO</font>

I recommend that you add these parameters to your $fields array:

$fields = array(
  'ID'   => $track . '|', // <---- se le DEBE poner un | (pipe) al final
  'Go'   => 1,
  'Type' => 'T'
);

// Utiliza http_build_query en vez del foreach + rtrim que estás usando
$fields_string = http_build_query($fields);
    
answered by 23.08.2016 в 10:18
0
$fields = array( 'Data'=>$track, 'Go' => 1, 'ID' => $track.'|', 'Type' => 'T', 'OpenWindowNoMenuSystemKey'=>'');

    
answered by 09.12.2017 в 00:08