php - How to extract required data from CURL response? -


here response getting. want extract access_token. how can this. please help.

http/1.1 200 ok via: 1.1 lvqma554 (), 1.1 lvqma554 ()  transfer-encoding: chunked  connection: keep-alive  x-correlationid: id-e41cc17c551ba0be17900000 0; id-9a8a03a2551ba0be02907400 0  cache-control: no-store  date: wed, 01 apr 2015 07:39:42 gmt  pragma: no-cache  server: apache-coyote/1.1  x-amex-dpg-deprecated: no  x-amex-dpg-msg-id: id-e41cc17c551ba0be17900000  x-amex-dpg-status: success  content-type: application/json;charset=utf-8  {      "access_token" : "7612126f-dea3-449b-b349-94be115e938a",     "token_type" : "mac",      "expires_in" : 7200,      "refresh_token" : "bc17169d-4fa0-407f-976f-32b2b4ef8812",      "scope" : "card_info",     "mac_key" : "537d3fc2-6a86-456a-b38b-60f77fe79a45",      "mac_algorithm" : "hmac-sha-1"  } 

it json string:

$a = '{ "access_token" : "7612126f-dea3-449b-b349-94be115e938a", "token_type" : "mac", "expires_in" : 7200, "refresh_token" : "bc17169d-4fa0-407f-976f-32b2b4ef8812", "scope" : "card_info", "mac_key" : "537d3fc2-6a86-456a-b38b-60f77fe79a45", "mac_algorithm" : "hmac-sha-1" }'; $b = json_decode($a,true);//here json string decoded , returned associative array echo $b['access_token']; 

yields:

7612126f-dea3-449b-b349-94be115e938a 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -