if ($cron->get_cron_state('bot_tweets') == 1) {
        echo mainFuncs::push_response(24);
        $run_cron = false;
    }
}
if ($run_cron != true) {
    exit;
}
if (!is_connected()) {
    //internet connection seems broken
    exit;
}
$db->output_error = 1;
//Set cron status
$cron->set_cron_state('bot_tweets', 1);
$cron->set_log(1);
$ap_creds = $db->get_ap_creds();
$configs = $db->query("\n    SELECT *\n      FROM " . DB_PREFIX . "users_config\n     WHERE tweet_bot_status=1;\n");
while ($userConfig = mysql_fetch_array($configs, MYSQL_ASSOC)) {
    $cron->set_user_id($userConfig['user_id']);
    $tweetRate = $userConfig['tweeting_rate'];
    $authUserData = $db->get_user_data($userConfig['user_id']);
    $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $authUserData['oauth_token'], $authUserData['oauth_token_secret']);
    $tweetsToSend = $db->query("\n        SELECT id, tweet_content\n          FROM " . DB_PREFIX . "tweets_queue\n         WHERE datetime_tweeted IS NULL\n               AND user_id='{$userConfig['user_id']}'\n         LIMIT {$tweetRate};\n    ");
    while ($tweet = mysql_fetch_array($tweetsToSend, MYSQL_ASSOC)) {
        $connection->post('statuses/update', array('status' => $tweet['tweet_content']));
        //Log result - reasons for a non 200 include duplicate tweets, too many tweets
        //posted in a period of time, etc etc.
        if ($connection->http_code == 200) {
            $cron->store_cron_log(7, $cron_txts[18] . $tweet['tweet_content'] . $cron_txts[19], '');
        } else {
Exemple #2
0
 New to 0.3 - Some people on super cheap hosting seem to get
 SQL errors - output them if they occur
 */
 $db->output_error = 1;
 //Set cron status
 $cron->set_cron_state('follow', 1);
 //Get credentials
 $ap_creds = $db->get_ap_creds();
 //Loop through all accounts
 $q1 = $db->query("SELECT * FROM " . DB_PREFIX . "authed_users ORDER BY (followers_count + friends_count) ASC");
 while ($q1a = $db->fetch_array($q1)) {
     //Defines
     $connection = new TwitterOAuth($ap_creds['consumer_key'], $ap_creds['consumer_secret'], $q1a['oauth_token'], $q1a['oauth_token_secret']);
     $cron->set_user_id($q1a['id']);
     $cron->set_first_pass_done($q1a['fr_fw_fp']);
     $cron->set_log($q1a['log_data']);
     $cron->set_throttle_time(0, 'fr');
     $cron->set_throttle_time(0, 'fw');
     $cron->set_fr_fw_issue(0);
     //Refresh details
     $content = $connection->get('account/verify_credentials');
     if ($connection->http_code == 200) {
         //Update DB
         $tw_user = array('id' => $q1a['id'], 'profile_image_url' => $content->profile_image_url, 'screen_name' => $content->screen_name, 'followers_count' => $content->followers_count, 'friends_count' => $content->friends_count, 'last_updated' => date("Y-m-d H:i:s"));
         $db->store_authed_user($tw_user);
         /*
         API Version 1.1 has really killed the limits here; from 350 per hour to 15 per
         15 minutes. Also Follower and Friend lists are now separately rate limited; code
         adjusted below to set individual throttle rates. Thanks Twitter, real helpful (not).
         
         On the plus side, these limits are now not used up elsewhere in the application