I am consuming a webservice in PHP , below is code sample
> if ( $datas=file_get_contents($url) ) return json_decode($datas); > return Array('error' => "Can't open url");
I return the the value of above function call to js page. but I dont get the value of webservice call in js but always get error value. However if I open the $url in browser I get below data (valid json) :
{"d":[ [ 5.305,428 ] ] }
Due to framework restriction i can use only json_decode() to return values back to my js page. I also tried json_decode($datas,true); but still no help.
I also tried consuming same code in standalone php file : I get this error : when I use json_decode($datas)
Catchable fatal error: Object of class stdClass could not be converted to string in C:\xampp\htdocs\webservice-demo\clientRestTest.php on line 32
and below error if I use json_decode($datas,true);
Notice: Array to string conversion in C:\xampp\htdocs\webservice-demo\clientRestTest.php on line 32 Array
Please let me know how to resolve the issue .