Beispiel #1
0
/**
 * Post scheduled tweets to twitter.
 * @return [type] [description]
 */
function perch_twitter_post_tweets()
{
    $found = 0;
    $API = new PerchAPI(1.0, 'perch_twitter');
    $Twitter = new PerchTwitter($API);
    $found = $Twitter->post_scheduled_tweets();
    return $found;
}
Beispiel #2
0
 /**
  * Read in the form input, prepare data for storage in the database.
  *
  * @param string $post 
  * @param object $Item 
  * @return void
  * @author Rachel Andrew
  */
 public function get_raw($post = false, $Item = false)
 {
     $id = $this->Tag->id();
     $template = $this->Tag->template();
     if ($post === false) {
         $post = $_POST;
     }
     if (isset($post[$id])) {
         $this->raw_item = trim($post[$id]);
         $status_id = $this->raw_item;
         if (!is_numeric($status_id)) {
             $status_id = $this->_find_status_from_url($status_id);
         }
         if (is_object($Item)) {
             $json = PerchUtil::json_safe_decode($Item->itemJSON(), true);
             if (isset($json[$id]) && isset($json[$id]['status_id'])) {
                 if ($status_id == $json[$id]['status_id']) {
                     // Status ID hasn't changed, so return what we've got.
                     return $json[$id];
                 }
             }
         }
         $tweet = $this->get_status($status_id);
         $PerchTwitter = new PerchTwitter();
         $data = array();
         $data['tweetUser'] = trim($tweet->user->screen_name);
         $data['tweetUserRealName'] = trim($tweet->user->name);
         $data['tweetUserAvatar'] = trim($tweet->user->profile_image_url);
         $data['tweetDate'] = date('Y:m:d H:i:s', strtotime($tweet->created_at));
         $data['tweetTimeOffset'] = (int) $tweet->user->utc_offset;
         $data['tweetText'] = trim($tweet->text);
         $data['tweetAccount'] = trim($tweet->user->id);
         $data['tweetTwitterID'] = $status_id;
         $data['tweetHTML'] = $PerchTwitter->get_tweet_html($tweet);
         $data['tweetType'] = 'single';
         $data['status_id'] = $status_id;
         $data['template'] = $template;
         return $data;
     }
     return false;
 }
Beispiel #3
0
$CurrentSettings = $TwitterSettings->find();
if (!is_object($CurrentSettings)) {
    $TwitterSettings->attempt_install();
    $CurrentSettings = $TwitterSettings->find();
}
$details = array();
if ($CurrentSettings) {
    $details = $CurrentSettings->to_array();
} else {
    $details = false;
}
$message = '';
if ($Form->submitted()) {
    $postvars = array('settingTwitterID');
    $data = $Form->receive($postvars);
    $Twitter = new PerchTwitter();
    //update tweets
    $twitter_id_str = $data['settingTwitterID'];
    $twitter_id_array = explode(',', $twitter_id_str);
    for ($i = 0; $i < PerchUtil::count($twitter_id_array); $i++) {
        $twitter_id = trim($twitter_id_array[$i]);
        $Twitter->get_tweets('favorites', $twitter_id);
        $Twitter->get_tweets('mine', $twitter_id);
    }
    $message = $HTML->success_message('Tweets updated.');
}
if (!function_exists('curl_init')) {
    $message = $HTML->failure_message('You need the <a href="http://www.php.net/manual/en/ref.curl.php">PHP cURL functions</a> enabled in your hosting account to be able to use the Twitter app.');
}
$Paging = $API->get('Paging');
$Paging->set_per_page(20);