I hope you can help identify where I am making mistakes in the following code:
public function yee() {
$json = array();
$params = array(
'token' => $this->_token,
'receiver_name' => 'Test Name',
'sender_city' => 'copenhagen',
'sender_country' => 'DK',
'order_id' => 150
);
$ch = curl_init();
$query = http_build_query($params);
curl_setopt($ch, CURLOPT_URL, self::API_ENDPOINT . '/' . 'shipments/imported_shipment');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$http_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
$output = json_decode($output, true);
if ($http_code != 200){
if(is_array($output['message'])){
$json['error'] = $output['message'];
}else{
$json['error'] = $output['message'];
}
} else {
$json['error'] = "Import Successully";
}
return $output;
}
}
I have this in my class.php file, along with a few more lines doing the authentication.
Then I try to call the function after initializing it:
$testObject->yee();
echo $testObject->yee(); ?>
The authentication part works correctly, as I'm also outputting tokens and a few other variables, however when I echo the yee() function - all it displays is "Array"
In case you didn't notice, I am extremely green in JSON/API territory, and my PHP skills are rusty at best. So I am hoping for any and all pointers to lead me closer to solving this. Thanks!