如何从卷曲响应中读取特定值

问题描述 投票:0回答:1

这是我的回复

我需要读取沙箱的第一行ID值和网址

{ 
 "id": "chg_g5Y25220190539Ob590811651", 
 "object": "charge",
 "live_mode": false,
 "api_version": "V2",
 "method": "CREATE",
 "status": "INITIATED",
 "amount": 1.000,
 "currency": "KWD",
 "threeDSecure": false,
 "card_threeDSecure": false,
 "save_card": false,
 "statement_descriptor": "Sample",
 "description": "Test DESC",
 "transaction": 
  {
    "timezone": "UTC+03:00",
    "created": "1573191592651",
    "url": "https://sandbox.payments.tap.company/test_gosell/v2/payment/response.aspx?tap_chg=PsV8hZdr78kEIAOZl9XL1B5u3dXe%2bBQ%2b3Hrd%2fempxYs%3d&sess=noWi606EI%2bM%3d&token=PsV8hZdr78kEIAOZl9XL1B5u3dXe%2bBQ%2bTyYdQy9iGpS6aAXwKOqAdw%3d%3d",
    "expiry": { "period": 30, "type": "MINUTE" },
    "asynchronous": false
  },
 "reference": { "transaction": "txn_0001", "order": "ord_0001" },
 "response":  { "code": "100", "message": "Initiated" },
 "receipt":   { "email": true, "sms": true },
 "customer":  { "first_name": "yxy", "last_name": "ttt", "email": "[email protected]" },
 "source":    { "object": "source", "id": "src_card" },
 "redirect": { "status": "PENDING", "url": "http://localhost:81/School/" },
 "post": { "status": "PENDING", "url": "http://localhost:81/School/" } }
php arrays json api php-curl
1个回答
0
投票

假设您有一个名为$resp的变量对curl的响应,>

$resp_decoded = json_decode($resp,TRUE);
print($resp_decoded['id']);
print($resp_decoded['transaction']['url']);
© www.soinside.com 2019 - 2024. All rights reserved.