2014-10-09 75 views
1

我已經集成在我的網站上的UPS運輸API,它允許用戶創建貨運標籤,並採取了打印出來的添加公司標誌,的UPS貨運標籤

被創建的標籤和用戶也可以打印標籤,但標籤正在生成,這基本上是從我使用的代碼返回的圖像文件,但我也想在其上添加公司徽標,請讓我知道我該怎麼做。

  • 以下是我用過由於您使用激光標籤來創建標籤

    function create_shipping_label($shipping_digest) { 
    // SHIP ACCEPT REQUEST 
    $xmlRequest1 = '<?xml version = "1.0″ encoding = "ISO-8859-1″?> 
    <AccessRequest> 
    <AccessLicenseNumber>' . UPS_ACCESS_LICENCE_NUMBER . '</AccessLicenseNumber> 
    <UserId>' . UPS_USERNAME . '</UserId> 
    <Password>' . UPS_PASSWORD . '</Password> 
    </AccessRequest> 
    <?xml version = "1.0″ encoding = "ISO-8859-1″?> 
    <ShipmentAcceptRequest> 
    <Request> 
    <TransactionReference> 
    <CustomerContext>Customer Comment</CustomerContext> 
    </TransactionReference> 
    <RequestAction>ShipAccept</RequestAction> 
    <RequestOption>1</RequestOption> 
    </Request> 
    <ShipmentDigest>' . $shipping_digest . '</ShipmentDigest> 
    </ShipmentAcceptRequest> 
    '; 
    
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, PREFIX."ups.com/ups.app/xml/ShipAccept"); 
    // uncomment the next line if you get curl error 60: error setting certificate verify locations 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    // uncommenting the next line is most likely not necessary in case of error 60 
    // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest1); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 3600); 
    $xmlResponse = curl_exec($ch); // SHIP ACCEPT RESPONSE 
    
    
    $xml = $xmlResponse; 
    
    
    
    preg_match_all("/\<ShipmentAcceptResponse\>(.*?)\<\/ShipmentAcceptResponse\>/s",  $xml, $bookblocks); 
    
    
    foreach ($bookblocks[1] as $block) { 
        preg_match_all("/\<GraphicImage\>(.*?)\<\/GraphicImage\>/", $block, $author); // GET LABEL 
        preg_match_all("/\<TrackingNumber\>(.*?)\<\/TrackingNumber\>/", $block, $tracking); // GET TRACKING NUMBER 
    
    
    
    // ($author[1][0] . "\n"); 
    

    }

      return '<img id="shipping_label_image" src="data:image/gif;base64,' . $author[1][0] . '"/>'; 
    

    }

回答

0

的代碼,你會只需要用c返回額外的HTML ompany圖像上方或下方的運輸標籤圖像。