我有一个应用程序(比如A1),它使用API从另一个应用程序(比如A2)获取数据。没有使用cURL获取数据
A2以PHP的序列化的格式返回数据。任何应用程序可以访问使用URL和查询字符串这些数据(其中还包含验证码)
http://example-a2.com/index.php?process=get_results&time=today&auth_code=123456
返回数据(数据不完整,只是想表明它在连载的方式返回数据,当我在浏览器上面输入URL)
a:425:{s:10:"2010-02-19";a:0:{}s:10:"2010-02-20";a:0:{}s:10:"2010-02-21";a:0:{}s:10:"2010-02-22";a:0:{}s:10:"2010-02-23";a:0:{}s:10:"2010-02-24";a:0:{}s:10:"2010-02-25";a:0:{}s:10:"2010-02-26";a:0:{}s:10:"2010-02-27";a:0:{}s:10:"2010-02-28";a:0:{}s:10:"2010-03-01";a:0:{}s:10:"2010-03-02";a:0:{}s:10:"2010-03-03";a:0:{}s:10:"2010-03-04";a:0:{}s:10:"2010-03-05";a:0:{}s:10:"2010-03-06";a:0:{}s:10:"2010-03-07";a:0:{}s:10:"2010-03-08";a:0:{}s:10:"2010-03-09";a:0:{}s:10:"2010-03-10";a:0:{}s:10:"2010-03-11";a:0:{}s:10:"2010-03-12";a:0:{}s:10:"2010-03-13";a:0:{}s:10:"2010-03-14";a:0:{}s:10:"2010-03-15";a:0:{}s:10:"2010-03-16";a:0:{}s:10:"2010-03-17";a:0:{}s:10:"2010-03-18";a:0:{}s:10:"2010-03-19";a:0:{}s:10:"2010-03-20";a:0:{}s:10:"2010-03-21";a:0:{}s:10:"2010-03-22";a:0:{}s:10:"2010-03-23";a:0:{}s:10:"2010-03-24";a:0:{}s:10:"2010-03-25";a:0:{}s:10:"2
现在的问题是,我不能够获取应用A1使用卷曲序列化的数据。
我使用下面的代码
$url = 'http://example-a2.com/index.php?process=get_results&time=today&auth_code=123456';
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print 'sorry';
}
else
{
var_dump($buffer);
}
,我得到以下输出
string(165) " "
有人能指出我出来有什么不好的代码?
我假设在这里粘贴代码时,URL不匹配是一个错字: - ? – 2011-04-20 09:41:46
@ÁlvaroG. Vicario:我在编辑那个,这是错字。抱歉。 – 2011-04-20 09:42:20
我的代码中没有看到任何内在错误。您的应用是否需要cookie或发出HTTP重定向? – 2011-04-20 09:47:44