0

I am creating a Courier tracking plugin and get data using their API. The output they are returned is in JSON format. Here is the courier API

$curl_handle = curl_init();
// For Direct Link Access use below commented link
//curl_setopt($curl_handle, CURLOPT_URL, 'http://new.leopardscod.com/webservice/trackBookedPacket/?api_key=XXXX&api_password=XXXX&track_numbers=XXXXXXXX');  // For Get Mother/Direct Link

curl_setopt($curl_handle, CURLOPT_URL, 'http://new.leopardscod.com/webservice/trackBookedPacket/format/json/');  // Write here Test or Production Link
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array(
    'api_key' => 'your_api_key'
    'api_password' => 'your_api_password'
    'track_numbers' => 'string'                      // E.g. 'XXYYYYYYYY' OR 'XXYYYYYYYY,XXYYYYYYYY,XXYYYYYY' 10 Digits each number
));

$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

How to echo the values get from this curl command?

Regards

Iqbal
  • 9
  • 4

1 Answers1

0

Please use json_decode function after $buffer = curl_exec($curl_handle);

$buffer = curl_exec($curl_handle);
$json = json_decode($buffer, true);
print_r($json);

You can get PHP object array

Mohsin Marui
  • 459
  • 2
  • 8