1

我试图集成 USPS 包裹提取 API 并收到授权错误。

'80040b1a 授权失败。也许用户名和/或密码不正确。UspsCom::DoAuth'

我使用的是 USPS 文档中的相同代码。

https://www.usps.com/business/web-tools-apis/package-pickup.htm

以下是我的完整代码。

<?php
    $url = "https://stg-secure.shippingapis.com/ShippingAPI.dll";
    $ch = curl_init();

    // set the target url
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

    // parameters to post
    curl_setopt($ch, CURLOPT_POST, 1);

    $data = 'API=CarrierPickupAvailability&XML=<CarrierPickupAvailabilityRequest USERID="013ODDPA7467" PASSWORD="XXXX" > 
        <FirmName>ABC Corp.</FirmName>
        <SuiteOrApt>Suite 777</SuiteOrApt>
        <Address2>1390 Market Street</Address2>
        <Urbanization></Urbanization>
        <City>Houston</City>
        <State>TX</State>
        <ZIP5>77058</ZIP5>
        <ZIP4>1234</ZIP4>
        </CarrierPickupAvailabilityRequest>';

    //send the POST values to USPS
    curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
    $result=curl_exec ($ch);
    //return $result;
    echo "<pre>";
    print_r($result);
?>

请帮助解决这个问题

4

0 回答 0