【问题标题】:Add company logo on the UPS shipping label在 UPS 运输标签上添加公司徽标
【发布时间】:2014-10-09 06:04:33
【问题描述】:

我在我的网站中集成了 UPS 运输 API,它允许用户创建运输标签并从中打印出来,

标签已创建,用户也可以打印标签,但是标签正在生成,这基本上是从我正在使用的代码返回的图像文件,但我还想在其上添加公司徽标,请告诉我该怎么做。

  • 以下是我用来创建标签的代码

     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] . '"/>';
    

    }

【问题讨论】:

    标签: php api shipping ups


    【解决方案1】:

    由于您使用的是激光标签,因此您只需返回带有公司图片的附加 HTML,该公司图片位于发货标签图片的上方或下方。

    【讨论】:

      猜你喜欢
      • 2015-10-05
      • 1970-01-01
      • 2018-08-10
      • 2021-08-22
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      • 2016-06-27
      • 1970-01-01
      相关资源
      最近更新 更多