public function post_scheduled_tweets() { if (!class_exists('tmhOAuth')) { require 'tmhOAuth/tmhOAuth.php'; require 'tmhOAuth/tmhUtilities.php'; } $Tweets = new PerchTwitter_Tweets(); $tweets = $Tweets->get_scheduled_tweets(); $sent = 0; if (PerchUtil::count($tweets)) { $TwitterSettings = new PerchTwitter_Settings(); $CurrentSettings = $TwitterSettings->find(); $tmhOAuth = new tmhOAuth(array('consumer_key' => $CurrentSettings->settingTwitterKey(), 'consumer_secret' => $CurrentSettings->settingTwitterSecret(), 'user_token' => $CurrentSettings->settingTwitterToken(), 'user_secret' => $CurrentSettings->settingTwitterTokenSecret())); foreach ($tweets as $tweet) { $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update.json'), array('status' => $tweet['tweetStatus'])); if ($code == 200) { $sent++; $Tweets->mark_scheduled_as_sent($tweet['tweetID']); } else { PerchUtil::debug(PerchUtil::json_safe_decode($tmhOAuth->response['response'])); } } } return $sent; }