使用 PHP 的 Fedex SOAP API 请求多个跟踪号码

2024-01-02

我希望将所有 FedEx 跟踪信息缓存在我自己的数据库中,我的公司每天大约有 150 多个跟踪号码。根据这个链接,

http://www.fedex.com/us/developer/product/WebServices/MyWebHelp_August2010/Content/Proprietary_Developer_Guide/tTracking_and_Visibility_Services_condtionalized.htm http://www.fedex.com/us/developer/product/WebServices/MyWebHelp_August2010/Content/Proprietary_Developer_Guide/tTracking_and_Visibility_Services_condtionalized.htm

Fedex 服务不支持批量处理?这是否意味着我需要对每个跟踪号码进行一次调用?我用了大约 80 秒的时间就完成了一天的销售。

目前没有更好的选择吗?或者有更好的方法或流程来做到这一点?


使用此代码希望它能帮助您

TrackRequest request = CreateFedexMultipleTrackRequest(TrackingCode);
 TrackService service = new TrackService();
 TrackReply reply = service.track(request);
 if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
 {
   reply.CompletedTrackDetails//now manage All tracking As Your Need
 }
 //go to How to create single request for multiple tracking numbers at a time
 private static TrackRequest CreateFedexMultipleTrackRequest(string TrackingNumber)
    {
        //string[] str = new string[] {TrackingNumber};
        string[] staticIntArray = TrackingNumber.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        //int arraycount = staticIntArray.Count();
        TrackRequest request = new TrackRequest();
        request.WebAuthenticationDetail = new WebAuthenticationDetail();
        request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.UserCredential.Key = Application.FedexKey;
        request.WebAuthenticationDetail.UserCredential.Password = Application.FedexPassword;
        request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.ParentCredential.Key = Application.FedexKey;
        request.WebAuthenticationDetail.ParentCredential.Password = Application.FedexPassword;
        request.ClientDetail = new ClientDetail();
        request.ClientDetail.AccountNumber = Application.FedexAccountNumber;
        request.ClientDetail.MeterNumber = Application.FedexMeterNumber;
        request.TransactionDetail = new TransactionDetail();
        request.TransactionDetail.CustomerTransactionId = "NA";  //This is a reference field for the customer.  Any value can be used and will be provided in the response.
        request.Version = new VersionId();
        // Tracking information
        request.SelectionDetails = new TrackSelectionDetail[staticIntArray.Length];
        for (int j = 0; j <= staticIntArray.Length - 1; j++) { request.SelectionDetails[j] = new TrackSelectionDetail(); }
        for (int i = 0; i <= staticIntArray.Length - 1; i++)
        {
            request.SelectionDetails[i].PackageIdentifier = new TrackPackageIdentifier();
            request.SelectionDetails[i].PackageIdentifier.Value = staticIntArray[i]; //tracking number or door tag
            request.SelectionDetails[i].PackageIdentifier.Type = TrackIdentifierType.DOCUMENT_AIRWAY_BILL;
            request.SelectionDetails[i].ShipmentAccountNumber = "XXX";
            // Date range is optional.
            // If omitted, set to false
            request.SelectionDetails[i].ShipDateRangeBegin = DateTime.Parse("05/09/2016"); //MM/DD/YYYY
            request.SelectionDetails[i].ShipDateRangeEnd = request.SelectionDetails[0].ShipDateRangeBegin.AddDays(0);
            request.SelectionDetails[i].ShipDateRangeBeginSpecified = true;
            request.SelectionDetails[i].ShipDateRangeEndSpecified = true;
        }
        // Include detailed scans is optional.
        // If omitted, set to false
        request.ProcessingOptions = new TrackRequestProcessingOptionType[1];
        request.ProcessingOptions[0] = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS;
        return request;
    }

//您可以在 fedex 中一次追踪 30 个号码

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 PHP 的 Fedex SOAP API 请求多个跟踪号码 的相关文章

  • WordPress 中的 add_action 函数

    嗯 我正在学习创建一个 WordPress 插件 我下载了一个并阅读了代码 然后我看到了这个 我假设 foo 是它将添加操作的标签 但是 array 到底是做什么的呢 add action foo array foo1 foo2 我在看ht
  • ORDER BY 字段内的 MySQL 子查询。 (没有内连接)

    有很多与此相关的问题 但都具有使用内部联接的相同答案 这 我认为 在这里是不可能的 如果我错了请告诉我 我现在正在做的是调用两个不同的 mysql 查询来获取结果 它工作完美 db gt query SELECT FROM meta WHE
  • PHP MySql 百分比

    我的问题是关于百分比 我不是专家 所以我会尽力以更好的方式进行解释 我的 mysql 服务器中有一个表 假设有 700 条记录 如下所示 Name country language Birth Lucy UK EN 1980 Mari Ca
  • Zend Framework 生成唯一的字符串

    我想生成一个唯一的 4 6 个字符长的字母数字字符串 以便与每个记录 用户 一起保存在数据库中 db 字段具有唯一索引 因此尝试保存预先存在的字符串会生成错误 现在我正在生成一个随机字符串并使用 try catch 因此在添加新记录时如果抛
  • 搜索引擎如何找到相关内容? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 Google 在解析网络时如何找到相关内容 例如 Google 使用 PHP 原生 DOM 库来解析内
  • MySQL/PDO::quote() 尽管使用 PDO::PARAM_INT 参数,但仍在整数周围加上引号

    无论我传递给什么值 数据类型对 它都会出现 pdo gt quote value type 它总是将其引用为字符串 echo pdo gt quote foo PDO PARAM STR foo as expected echo pdo g
  • 在 php 中为类自动生成 getter 和 setter 的最佳方法是什么? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 我经常创建一个包含一些私有变量的类 当设置此类的实例时 应该可以使用 getter 和 setter 填充该类的所有变量 有没有一种简单的方法可
  • 生成大随机数 php [重复]

    这个问题在这里已经有答案了 我想使用 PHP 生成一个包含 75 个字符的数字 我到处寻找 但一无所获 除了这个 http dailycoding com tools RandomNumber aspx http dailycoding c
  • 如何在响应ajax codeigniter后停止执行其他控制器

    我想知道如何在响应输出 json 数据后停止执行函数和涉及的其他控制器 就我这里的情况而言 我只是打电话test 函数于dashboard控制器 In dashboard构造函数将执行MY Login library In MY Login
  • Woocommerce 让产品显示在存档页面中

    我正在尝试让所有产品显示在我商店的存档页面中 我想知道他们的id我正在使用我的一个钩子 它在 wp head 上运行并检查 if is product category 我想以某种方式访问 产品的查询并获取它们的 ID if is prod
  • posts_search 中的自定义查询

    如何使用此查询作为我的自定义搜索查询 add filter posts search my search is perfect 20 2 function my search is perfect search wp query sWord
  • 如何使用 php 下载/打印页面的特定部分

    我有一个 HTML 页面如下 Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the indust
  • 扩展蓝图类?

    我想覆盖timestamps 函数中发现Blueprint班级 我怎样才能做到这一点 e g public function up Schema create users function Blueprint table table gt
  • “使用未定义常量”注意,但该常量应该被定义

    共有三个文件 common php controller php 和 user php 文件 common php 如下所示 文件controller php看起来像 文件 user php 如下所示 执行脚本时 会给出通知 注意 使用未定
  • 为什么 iconv 在 php:7.4-fpm-alpine docker 中返回空字符串

    给出以下代码
  • 使用 SSL 证书验证 Web 浏览器

    是否可以使用 ssl 证书对 Web 浏览器进行身份验证 假设我在应用程序中存储私钥 有什么方法可以从浏览器读取密钥并尝试基于该私钥进行身份验证 您可以使用 SSL TLS 客户端证书身份验证来对浏览器 用户进行身份验证 服务器必须请求客户
  • 在 PHP 中撤销 Google 访问令牌

    正如标题所示 我想以编程方式撤销授予的访问令牌 即在 PHP 中 我发现这个他们的网站 https developers google com identity protocols OAuth2WebServer tokenrevoke 但
  • 覆盖控制器 Symfony 3.4/4.0

    我目前正在尝试覆盖 FOSUserBundle 中的控制器 在新的文档中 https symfony com doc 3 4 bundles override html https symfony com doc 3 4 bundles o
  • 表单计算器脚本基本价格未加载 OnLoad

    我的表单中有一个计算器来计算我的下拉选项选择 function select calculate on change calc input type checkbox calculate on click calc function cal
  • php,统计字符并删除超过140个字符的内容

    我需要一个 PHP 函数来计算短语的字符数 如果短语长度超过 140 个字符 则此函数应删除所有其他字符并在短语末尾添加三个点 例如我们有 message I am what I am and you are what you are et

随机推荐