Cron job + Twitter


#1

Hey all,
I have created a small app for personal use. What the app does is every hour starting from 12:30 (and going on to 1:30, 2:30, etc) it’ll post a static tweet. I am currently using themattharris’s twitter API. I have a cron job as well. I am hosted on JustHost for anyone that’s curious.

The issue I am having is that the PHP code works when I manually refresh index.php & my cron job semi-works. The email I get from my cron job is:

<!doctype html>
<html>
<body>
Error 200
</body>
</html>

What I like to know is, how can I get my cron work to fully work?!

CRON JOB:

30 * * * *	php -q /home1/USER_NAME/public_html/twitter/index.php

PHP CODE:

<!doctype html>
<html>
<body>
<?php
include 'tmhOAuth/tmhOAuth.php';

$tmhOAuth = new tmhOAuth(array(
  'consumer_key' => 'XXX',
  'consumer_secret' => 'XXX',
  'user_token' => 'XXX',
  'user_secret' => 'XXX',
));

// Bahrain's time zone
date_default_timezone_set ('Asia/Riyadh');

// Set status message
$timezone= date("g:i");
$tweetMessage = "It's now" .$timezone. "in Bahrain";

//Response
$response = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => $tweetMessage));
	
 //Do something if the request was unsuccessful	
if ($response != 200) {
    echo 'Error 200';
}

?>
</body>
</html>