Here is the Myhermes interegration code in php used to curl parcels and labels to give the barcode and pdf generated output when provided with client id and acces token.

<pre>
$urlapi="https://sandbox-api.myhermes.co.uk/api/";

$parceldata='{"parcels":[

{

"parcelDetails":{

"weightKg":"0.14",//Required fill

"itemDescription":"Be careful",//Required fill

"deliveryReference":"f2",//Required fill

"estimatedParcelValuePounds":0,

"compensationRequiredPounds":0,

"type":"STANDARD"

},

"clientUID":"Your Client Id",

"deliveryDetails":{

"deliveryAddress":{

"postcode":"SG40TJ",

"line1":"Dhariz Tech",

"line2":"11 Hunting Gate",

"line3":"Street",

"line4":"Aberdeenshire, Hitchin"

},

"firstName":"Dhariz",//Required fill

"lastName":"Tech",//Required fill

"email":"yourcustmeremailid@gmail.com",//Required fill

"telephone":"91908070604050 ",//Required fill

"signatureRequired":false,

"deliveryInstructions":"",

"deliverySafePlace":"",

"nextDay":false}

}

]

}';

$headers = array();

$headers[] = 'Accept: application/vnd.myhermes.parcelsummaries-v1+json';

$headers[] = 'Content-Type:application/vnd.myhermes.parcels-v1+json';

$headers[] = 'Authorization: Bearer {access-token-code}';

$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => $urlapi.'parcels',

CURLOPT_RETURNTRANSFER => true,

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 30,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_USERAGENT=> "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13",

CURLOPT_POSTFIELDS => $parceldata,

CURLOPT_HTTPHEADER => $headers,

));

$response = json_decode(curl_exec($curl));

$err = json_decode(curl_error($curl));

curl_close($curl);

if(isset($err)&&($err->error)){

echo '<h1>Error</h1>';

echo '<p>'.$err->error_description.'</p>';

}else{

$out1=$response->parcelSummaries;

$clientid=$out1[0]->clientUID;

$status=$out1[0]->status;

$barcode=$out1[0]->barcode;

if($clientid=='Your Client Id'){

if($status=='CREATED'){

$urllabel = $urlapi.'labels/'.$barcode.'?format=THERMAL';

$headerslabel = array("Accept: application/pdf; base64=true",

"Authorization: Bearer {access-token-code}");

$curllb = curl_init();

curl_setopt($curllb, CURLOPT_POST, 0);

curl_setopt($curllb, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($curllb, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curllb, CURLOPT_URL,$urllabel);

curl_setopt($curllb, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curllb, CURLOPT_HTTPHEADER,$headerslabel);

curl_setopt($curllb, CURLOPT_CUSTOMREQUEST,'GET');

$responselb=curl_exec($curllb);

curl_close($curllb);

echo '<iframe width="918" height="700" src="data:application/pdf;base64,'.$responselb.'"></iframe>';

//echo '<img src="data:image/png;base64,'.$responselb.'" />'; "Accept: image/png; base64=true",

$dataimg = base64_decode($responselb);

//file_put_contents('uploads/'.$barcode.'-image.png', $dataimg);

}

}

}
</pre>