php - Getting blank array from web service -


i having strange problem in consuming web services created on server.

this url of web services created

http://52.53.227.143/api_test.php?post_name=bsn%20syntha-6%20isolate

i can't able receive data in array or other format on site. used both file_get_content , curl receive json format, giving me blank array.

here code:

$post_name = 'bsn syntha-6 isolate'; $base = "http://52.53.227.143/api_test.php?post_name=".$post_name; $str = file_get_contents($base); echo '<pre>'; print_r(json_decode($str)); 

its giving me following result:

stdclass object ( [info] => array     (     )  ) 

i use curl, here's code:

$curl = curl_init(); curl_setopt($curl, curlopt_ssl_verifypeer, false); curl_setopt($curl, curlopt_header, false); curl_setopt($curl, curlopt_followlocation, true); curl_setopt($curl, curlopt_url, $base); curl_setopt($curl, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.3) gecko/20100401 firefox/3.6.3');  curl_setopt($curl, curlopt_referer, 'http://www.google.com'); curl_setopt($curl, curlopt_returntransfer, true); $str = curl_exec($curl); curl_close($curl); echo '<pre>'; print_r(json_decode($str)); 

please me.

use urlencode()

this working :

<?php     $post_name = 'bsn syntha-6 isolate';     $base = "http://52.53.227.143/api_test.php?post_name=" . urlencode($post_name);     $str = file_get_contents($base);     echo '<pre>';     print_r(json_decode($str)); ?> 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -