Example #1
0
 case 'email':
     $bot->collectNewFollowers();
     break;
 case 'dm':
     $bot->collectNewDMs();
     break;
 case 'replies':
     $bot->collectNewReplies();
     break;
 case 'ticker':
     /* Fetch the latest reminder data, convert it to a JSON object
        and then save it to a cache */
     $reminder = new Reminder();
     $options = new OptionsHandler();
     $reminderData = array();
     $lastId = $options->getValue('last_ticker_id');
     $latestPublicReminders = $reminder->fetchLatestPublic($lastId);
     if ($latestPublicReminders) {
         $i = 0;
         $latestId = $lastId;
         while ($reminderData = $latestPublicReminders->getRow()) {
             if ($i == 0) {
                 $latestId = $reminderData['reminder_id'];
             }
             $reminderData[$i] = $reminderData;
             $i++;
         }
     }
     $json = fopen(MINDMETO_ROOT . 'cache/ticker.json', 'w');
     fwrite($json, json_encode($reminderData));
     fclose($json);
Example #2
0
 function collectNewDMs()
 {
     global $db;
     $options = new OptionsHandler();
     $currentLastId = trim($options->getValue('last_dm_id'));
     try {
         if ($currentLastId > 0) {
             $data = array('since_id' => $currentLastId, 'count' => '200');
         } else {
             $data = array('count' => '200');
         }
         $updates = $this->twitterOAuth->OAuthRequest('https://twitter.com/direct_messages.json', $data, 'GET');
     } catch (Exception $e) {
         if (strlen($e->getMessage()) > 0) {
             die("There was a problem grabbing MindMeTo's DMs (" . $e->getMessage() . ")");
         } else {
             die;
         }
     }
     $updatesJSON = json_decode($updates);
     if (count($updatesJSON) > 0) {
         $lastId = $this->parseTweets("dm", $updatesJSON, $currentLastId);
         $options->setValue('last_dm_id', $lastId);
     }
 }