CodeIgniter Forums
How to create and print shipment label using codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to create and print shipment label using codeigniter (/showthread.php?tid=68703)



How to create and print shipment label using codeigniter - sophia - 08-15-2017

Code:
Hi, would like to enquire how to create and print shipment label from own website using rest api. Have change the code
below based on     https://docs.postmen.com/dhl-global-mail-asia.html?sdk=php#labels-create-a-label. Please advise. Thanks.

POST
<?php
    
        $url = 'https://sandbox.api.com/v3/labels';
        $method = 'POST';
        $headers = array(
            "content-type: application/json",
            "api-key: secretkey"
        );
        $body = '{"labelreq":{
            "accesstoken":""
            },
            "shipperaddr":{
            "company":"",
            },
            "consigneeaddr":{
            "address":""
             },
           }';
    
        $curl = curl_init();
    
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_URL => $url,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_HTTPHEADER => $headers,
            CURLOPT_POSTFIELDS => $body
        ));
    
        $response = curl_exec($curl);
        $err = curl_error($curl);
    
        curl_close($curl);
    
        if ($err) {
            echo "cURL Error #:" . $err;
        } else {
            echo $response;
        }
    ?>
    

GET


<?php
    
        $url = 'https://sandbox.api.com/v3/labels/accesstokenkey';
        $method = 'GET';
        $headers = array(
            "content-type: application/json",
            "api-key: secretkey"
        );
    
        $curl = curl_init();
    
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_URL => $url,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_HTTPHEADER => $headers,
        ));
    
        $response = curl_exec($curl);
        $err = curl_error($curl);
    
        curl_close($curl);
    
        if ($err) {
            echo "cURL Error #:" . $err;
        } else {
            echo $response;
        }
    ?>



RE: How to create and print shipment label using codeigniter - jarmen_kell - 08-15-2017

well... ?
have you tried it?
what's the result?
is it what you've expected?
if not? what would it be?
what's the specific details on what you're trying to achieve here?