I am creating http_client object and making a GET request. Below is my code.
$httpc = new HTTP_CLIENT();
$httpc->get("$endpointUrl?operation=getchallenge&username=$userName");
$response = $httpc->currentResponse();
print_r($response);
output: Array ( [url] => http://localhost:8888//webservice.php?operation=getchallenge&username=admin [code] => 200 [headers] => Array ( [date] => Thu, 27 Sep 2012 07:30:17 GMT [server] => Apache/2.0.52 (Win32) PHP/5.2.6 [x-powered-by] => PHP/5.2.6 [expires] => Thu, 19 Nov 1981 08:52:00 GMT [cache-control] => no-store, no-cache, must-revalidate, post-check=0, pre-check=0 [pragma] => no-cache [content-length] => 102 [connection] => close [content-type] => application/json ) [body] => {"success":true,"result":{"token":"50640089780c4","serverTime":1348731017,"expireTime":1348731317}} )
jsonResponse = Zend_JSON::decode($response['body']);
I tried to extract “body” part from this Array, but value i get is blank. Help me if you can.
Note : You can see the output having JUNK value at starting of [body] part.
Since that is an API and they clearly have some BOM characters your should exatrct them and decode: