从web服务获取空白数组


Getting blank array from web service

我在使用我在另一台服务器上创建的web服务时遇到了一个非常奇怪的问题。

这是我创建的web服务的URL

http://52.53.227.143/API_test.php?post_name = BSN % 20 syntha-6 % 20隔离

我无法在我的网站上接收数组或任何其他格式的数据。我使用file_get_content和curl来接收json格式,但它只给我空白数组。

下面是我的代码:
$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));

它给了我以下结果:

stdClass Object
(
[info] => Array
    (
    )
)

我也使用Curl,下面是代码:

$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));

请帮帮我。

Use urlencode()

正在运行:

<?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));
?>