php - 如何解析来自 Easyship webhook 的响应
问题描述
我正在与 Easyship 合作,并尝试在订单状态发生变化时解析来自他们的 webhook 的响应。首先,我什至无法接收数据,并尝试了以下方法:
print_r($_POST, TRUE)
print_r($_GET, TRUE)
print_r($_REQUEST, TRUE)
print_r(file_get_contents("php://input"), TRUE)
只有最后一个接收任何数据。我收到的数据如下:
@"event_type":"shipment.tracking.checkpoints.created","resource_type":"shipment","resource_id":"ESHK25561976","tracking_status":{"easyship_shipment_id":"ESHK25561976","platform_order_number":"30","origin":"HK","destination":"HK","company_order_number":null,"status":"In Transit to Customer","tracking_number":"SF1042689716516","tracking_page_url":"https://www.trackmyshipment.co/shipment-tracking/ESHK25561976","checkpoints":[{"order_number":1,"handler":"SF Express Local","message":null,"location":null,"city":null,"country_name":"Hong Kong","country_iso3":"HKG","state":null,"postal_code":null,"checkpoint_time":"2020-10-16T17:47:10.802Z","primary_status":"Pending Pickup Confirmation",@"order_number":2,"handler":"SF Express Local","message":"Your package has been prepared and is awaiting pickup from SF Express Local","location":null,"city":null,"country_name":"Hong Kong","country_iso3":"HKG","state":null,"postal_code":null,"checkpoint_time":"2020-10-16T18:00:55.285Z","primary_status":"Awaiting Scan from Courier",@"order_number":101,"handler":"Sf Express","message":"【Hong Kong】 S.F. Express has picked up the shipment","location":"Hong Kong","city":"Hong Kong","country_name":null,"country_iso3":null,"state":null,"postal_code":null,"checkpoint_time":"2020-10-19T14:45:47.000Z","primary_status":"In Transit to Customer",@"order_number":102,"handler":"Sf Express","message":"【Hong Kong】 Shipment transiting to next station","location":"Hong Kong","city":"Hong Kong","country_name":null,"country_iso3":null,"state":null,"postal_code":null,"checkpoint_time":"2020-10-19T17:31:46.000Z","primary_status":"In Transit to Customer",@"order_number":103,"handler":"Sf Express","message":"【Hong Kong】 Shipment arrive at Hong Kong distribution center","location":"Hong Kong","city":"Hong Kong","country_name":null,"country_iso3":null,"state":null,"postal_code":null,"checkpoint_time":"2020-10-19T20:37:59.000Z","primary_status":"In Transit to Customer"]}}
我不确定如何解析它以提取我需要的信息。我尝试使用 json_decode 和 parse_str 的组合无济于事。
有小费吗?
解决方案
推荐阅读
- reactjs - 有什么方法可以在 reactJs 中使用 location.state.map 值来设置状态吗?
- ansible - Ansible - 从字典中获取列表值(Regsiter 变量)
- fedora - CodeLite 未在 Fedora 32 上启动
- python - 我的python代码有什么问题?我无法获得任何输出。?
- kotlin - 科特林。不显示目录中的文件
- rust - 如何解决 [E0382]:在 for 循环中使用移动值?
- laravel - 返回除deleted_at(softdeletes)之外的表laravel
- javascript - SyntaxError: await 仅在异步函数中有效,discord bot
- django - 在 Django 中构建报表
- python - 为单链表实现按索引值删除节点