php reading json result from http post -
i http post server , trying value of session_token out of results below how can that?
my post:
curl_setopt($ch,curlopt_url, $url); curl_setopt( $ch, curlopt_post, true); curl_setopt($ch,curlopt_returntransfer,true); curl_setopt($ch,curlopt_postfields, http_build_query($data)); curl_setopt( $ch, curlopt_httpheader, array('x-http-method-override: post','content-type:application/x-www-form-urlencoded','content-length: ' . strlen(http_build_query($data)))); curl_setopt($ch, curlopt_header, 1); curl_setopt($ch, curlinfo_header_out, true); curl_setopt($ch,curlopt_ssl_verifypeer, false); $response = curl_exec( $ch ); print_r($response);
the response:
http/1.1 200 ok date: tue, 07 jul 2015 19:12:25 gmt server: apache/2.4.10 (win32) openssl/1.0.1i mod_wsgi/3.5 python/2.7.8 content-length: 180 content-type: application/json {"guid": null, "session_token": "0kndd67a0dptosqodpsucuoasrnxtxnmqme29grkx0skaxekh3wyais6arokh4ethf6ytc8unotbhwspm61jjwqnx1mxbhbflji8z56yba6dpuvaynta0lvrnugzxwc5", "success": true}
i have tried json_decode returns null.
turn off/remove these options:
curl_setopt($ch, curlopt_header, 1); curl_setopt($ch, curlinfo_header_out, true);
they're causing http response headers included in $response
, makes response "random http-related text + json", instead of "json".
Comments
Post a Comment