php 在UPS运输标签上添加公司徽标

gcxthw6b  于 2023-01-16  发布在  PHP
关注(0)|答案(1)|浏览(168)

我已经集成了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] . '"/>';

}

carvr3hs

carvr3hs1#

由于您使用的是激光标签,您只需要返回附加的HTML,公司图像位于运输标签图像的上方或下方。

相关问题