Blank response from API when script called via cron


Hi all,

I wonder if anyone could shed some light on a problem that has me baffled. I’m trying to set up a PHP script to post a tweet once daily using cron (with REST 1.1’s POST statuses/update_with_media). The is script fired as expected (this is confirmed by the standard cron email of echo output), but the Twitter API always returns a completely blank response – no error code, no nothing. (I have also tested this with GET statuses/user_timeline, with the same results.)

This is in contrast to local server testing AND calling the remote script via HTTP – with both of these my script operates as intended, this (hopefully) proving that I’m not hitting the rate limit (I should be nowhere near) and that my IP address hasn’t been blacklisted (which I’ve seen is a possible cause of blank responses).

The cron command I’ve been using is /usr/local/bin/php /home/[path to php file]. I’ve been hosting the script files one level above my public HTML folder to avoid access directly from HTTP (though moving the script into the public folder and calling from cron doesn’t cure the issue), and whilst I’ve played with a WGET command I haven’t been able to get the right mixture of permissions to allow WGET to fire the script but without outside HTTP access.

For the API connection I’m using the twitter-api-php library (, which definitely works from cron (the author has assured me of this, and a colleague uses the library in that capacity).

Does anyone have any idea what could be wrong? Is there something really obvious I’m not taking into account?


Solution figured out: actually, it wasn’t a blank response from the API, it was no response being received at all. The library I used to access the Twitter API wasn’t informing me of cURL errors, and when I modified it to show such errors I was greeted with:

cURL error: error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

There are two solutions, both detailed in Chris Schuld’s post on the matter ( I discussed this issue with the author of the twitter-api-php library and he said he would add exceptions for cURL errors sometime in the future.