Forums » Developers



HTTP Request Failed

Disclaimer: I'm attempting to download data for a higher-traffic site (I noticed one successful request returned 10,000 records).

Usually, however, I am not successful in getting data. Using file_get_contents, I get the "failed to open stream: HTTP request failed!" error.

I'm using the same script to access other sites and they return data successfully. I figure it's something related to this large data set, or maybe I hit some kind of access quota already.

This is the URL in my PHP script:
$api_url = "http://api.getclicky.com/api/stats/4?site_id={$site_id}&sitekey={$site_key}&limit=all&type={$type}&date={$date}&output={$output}&page={$page}";

Right now I'm setting date=yesterday (which is what I will be usually doing) and output=json. As for type I'm only doing actions-list and visitors-list.

I'm open to using cURL, btw, if that helps any. I'm familiar with it and setting various request headers.

Posted Thu Jan 5 2012 8:08am by frank_instinct


For high traffic sites, exports may take a while. PHP by default will time out after 60 seconds of trying to connect, so you need to increase the limit (not a way to do "unlimited" unfortunately) so it has as much time as it needs.

set_time_limit(0);
ini_set('default_socket_timeout',1000);

Posted Mon Jan 9 2012 2:50pm by Your Friendly Clicky Admin



Reply to this discussion

You must be logged in to your account to post!