doujuan9698 2018-07-18 21:01
浏览 131
已采纳

为什么我的FedEx包裹送达时没有收到通知?

I'm using FedEx web services and jeremy-dunn/php-fedex-api-wrapper and attempting to have FedEx send me a plaintext email notification when a package has been delivered. I am using a third party for order fulfillment, and they have and use a different FedEx account that is not mine. (Maybe this is the problem?)

I can track the packages just fine, and when I attempt to subscribe to the delivery notification, the response from FedEx seems to indicate success. I am in testing mode. I'm NOT currently in production mode, in case that matters.

My request uses the following function:

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;
}

I use that function like this:

$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>';

And my response looks like this:

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"
      }
    }
  }
}

So it appears that I have subscribed, and that I should receive an email notification when the package is delivered, but the email never arrives. So I need help to know what's wrong with my code, or what's wrong with what I'm doing. I believe I understand what I'm doing, but no success.

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答