not getting data using cURL
I have an application (say A1), which fetches data from another application (say A2) using API.
A2 returns data in PHP's serialized format. Any application can access this data using a URL and query-string (which also contains authentication code)
http://example-a2.com/index.php?process=get_results&time=today&auth_code=123456
which returns data as (data is not complete, but just want to show that it returns data in serialize manner, when I type above URL in browser)
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
Now, problem is that I am not able to fetch serialized data using cURL in application A1.
I am using following code
$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);
}
and I get following output
string(165) " "
Can someone point me out what's wrong with the code?
I think you are not inspecting the real output:
string(165) " "
var_dump()
says you have a string of 165 bytes but only a white space is shown. If you are displaying it through a browser, make sure you send a Content-Type: text/plain
header or use the View Source feature.
精彩评论