簡體   English   中英

為什么我的FedEx包裹寄送時沒有收到通知?

[英]Why am I Not receiving a notification when my FedEx package is delivered?

我正在使用FedEx Web服務和jeremy-dunn / php-fedex-api-wrapper,並試圖在包裹交付后讓FedEx向我發送明文電子郵件通知。 我使用第三方來履行訂單,他們擁有並使用了另一個不是我的聯邦快遞帳戶。 (也許這是問題嗎?)

我可以很好地跟蹤包裹,當我嘗試訂閱傳遞通知時,FedEx的響應似乎表明成功。 我處於測試模式。 以防萬一,我目前不處於生產模式。

我的請求使用以下功能:

function fedexWebServicesNotificationSubscription( $trackingNumber, $recipient, $sender )
{
    global $fedexApiMode;

    if( ! is_array( $recipient ) OR ! isset( $recipient['email_addr'] ) )
        return FALSE;

    if( ! is_array( $sender ) OR ! isset( $sender['email_addr'], $sender['name'] ) )
        return FALSE;

    $userCredential = new ComplexType\WebAuthenticationCredential();
    $userCredential->setKey(FEDEX_KEY)
        ->setPassword(FEDEX_PASSWORD);

    $webAuthenticationDetail = new ComplexType\WebAuthenticationDetail();
    $webAuthenticationDetail->setUserCredential($userCredential);

    $clientDetail = new ComplexType\ClientDetail();
    $clientDetail->setAccountNumber(FEDEX_ACCOUNT_NUMBER)
        ->setMeterNumber(FEDEX_METER_NUMBER);

    $version = new ComplexType\VersionId();
    $version->setMajor(5)
        ->setIntermediate(0)
        ->setMinor(0)
        ->setServiceId('trck');

    $localization  = new ComplexType\Localization();
    $localization->setLocaleCode("US")
        ->setLanguageCode("EN");

    $emailRecip = new ComplexType\EMailNotificationRecipient();
    $emailRecip->setEMailNotificationRecipientType(SimpleType\EMailNotificationRecipientType::_SHIPPER)
        ->setEMailAddress( $recipient['email_addr'] )
        ->setLocalization($localization)
        ->setFormat(SimpleType\EMailNotificationFormatType::_TEXT)
        ->setNotificationEventsRequested([
                SimpleType\EMailNotificationEventType::_ON_DELIVERY,
                SimpleType\EMailNotificationEventType::_ON_EXCEPTION,
                SimpleType\EMailNotificationEventType::_ON_SHIPMENT,
                SimpleType\EMailNotificationEventType::_ON_TENDER
            ]);

    $emailNotificationDetail = new ComplexType\EMailNotificationDetail();
    $emailNotificationDetail->setPersonalMessage('Shipment Status Notification')
        ->setRecipients([$emailRecip]);

    $request = new ComplexType\TrackNotificationRequest();
    $request->setWebAuthenticationDetail($webAuthenticationDetail)
        ->setClientDetail($clientDetail)
        ->setVersion($version)
        ->setTrackingNumber( $trackingNumber )
        ->setSenderEMailAddress( $sender['email_addr'] )
        ->setSenderContactName( $sender['name'] )
        ->setNotificationDetail($emailNotificationDetail);

    $trackServiceRequest = new TrackService\Request();
    if( $fedexApiMode == 'production' )
        $trackServiceRequest->getSoapClient()->__setLocation(TrackService\Request::PRODUCTION_URL);
    $response = $trackServiceRequest->getGetTrackNotificationReply($request, TRUE);

    return $response;
}

我這樣使用該功能:

$trackingNumber = '781893213291';

$recipient = [
    'email_addr' => 'email@example.com'
];

$sender = [
    'email_addr' => 'email@example.com',
    'name'       => 'My Name'
];

$response = fedexWebServicesNotificationSubscription( $trackingNumber, $recipient, $sender );

echo '<pre>';
var_dump($response);
echo '</pre>';

我的回答如下:

object(stdClass)#28 (6) {
  ["HighestSeverity"]=>
  string(7) "SUCCESS"
  ["Notifications"]=>
  object(stdClass)#29 (5) {
    ["Severity"]=>
    string(7) "SUCCESS"
    ["Source"]=>
    string(4) "trck"
    ["Code"]=>
    string(1) "0"
    ["Message"]=>
    string(35) "Request was successfully processed."
    ["LocalizedMessage"]=>
    string(35) "Request was successfully processed."
  }
  ["Version"]=>
  object(stdClass)#30 (4) {
    ["ServiceId"]=>
    string(4) "trck"
    ["Major"]=>
    int(5)
    ["Intermediate"]=>
    int(0)
    ["Minor"]=>
    int(0)
  }
  ["DuplicateWaybill"]=>
  bool(false)
  ["MoreDataAvailable"]=>
  bool(false)
  ["Packages"]=>
  object(stdClass)#31 (6) {
    ["TrackingNumber"]=>
    string(12) "781893213291"
    ["TrackingNumberUniqueIdentifiers"]=>
    string(23) "12018~781893213291~FDEG"
    ["CarrierCode"]=>
    string(4) "FDXG"
    ["ShipDate"]=>
    string(10) "2018-07-17"
    ["Destination"]=>
    object(stdClass)#32 (4) {
      ["City"]=>
      string(13) "SAN FRANCISCO"
      ["StateOrProvinceCode"]=>
      string(2) "CA"
      ["CountryCode"]=>
      string(2) "US"
      ["Residential"]=>
      bool(false)
    }
    ["RecipientDetails"]=>
    object(stdClass)#33 (1) {
      ["NotificationEventsAvailable"]=>
      array(6) {
        [0]=>
        string(11) "ON_DELIVERY"
        [1]=>
        string(12) "ON_EXCEPTION"
        [2]=>
        string(12) "ON_EXCEPTION"
        [3]=>
        string(12) "ON_EXCEPTION"
        [4]=>
        string(12) "ON_EXCEPTION"
        [5]=>
        string(12) "ON_EXCEPTION"
      }
    }
  }
}

看來我已經訂閱了,並且包裹交付時我應該收到一封電子郵件通知,但是電子郵件從未到達。 因此,我需要幫助來了解我的代碼有什么問題,或我正在做的事情有什么問題。 我相信我了解自己在做什么,但沒有成功。

1)在測試模式下,不發送通知。 使用生產密鑰(生產模式),發送通知。 這就是我所期望的。

2)我的代碼和返回的響應都很好。

3)為未通過我的帳戶發送的包裹添加跟蹤通知就可以了。 添加跟蹤通知沒有任何限制,但總共可能只有4個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM