Php 如何从curl响应中读取特定值

Php 如何从curl响应中读取特定值,php,arrays,json,api,php-curl,Php,Arrays,Json,Api,Php Curl,这是我的回答 我需要读取沙盒的第一行id值和url { "id": "chg_g5Y25220190539Ob590811651", "object": "charge", "live_mode": false, "api_version": "V2", "method": "CREATE", "status": "INITIATED", "amount": 1.000, "currency": "KWD", "threeDSecure": false, "card_th

这是我的回答

我需要读取沙盒的第一行id值和url

{ 
 "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": "xyx@xyz.com" },
 "source":    { "object": "source", "id": "src_card" },
 "redirect": { "status": "PENDING", "url": "http://localhost:81/School/" },
 "post": { "status": "PENDING", "url": "http://localhost:81/School/" } }

假设curl在一个名为
$resp

$resp_decoded=json_decode($resp,TRUE);
打印($resp_decoded['id']);
打印($resp_decoded['transaction']['url']);