Welcome Guest, Not a member yet? Register   Sign In
How to create and print shipment label using codeigniter
#1

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;
        }
    ?>
Reply
#2

(This post was last modified: 08-15-2017, 06:45 PM by jarmen_kell.)

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?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB