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 (https://github.com/J7mbo/twitter-api-php), 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?