Beispiel #1
0
/**
 * 
 * function called by scripts (eg:a cron job or scheduled task) to upate the Tweets.
 */
function perch_twitter_update_tweets()
{
    $found = 0;
    $API = new PerchAPI(1.0, 'perch_twitter');
    PerchUtil::debug('Updating');
    $TwitterSettings = new PerchTwitter_Settings($API);
    $CurrentSettings = $TwitterSettings->find();
    if (is_object($CurrentSettings)) {
        $details = $CurrentSettings->to_array();
        $Twitter = new PerchTwitter();
        //update tweets
        $twitter_id_str = $details['settingTwitterID'];
        $twitter_id_array = explode(',', $twitter_id_str);
        for ($i = 0; $i < sizeOf($twitter_id_array); $i++) {
            $twitter_id = trim($twitter_id_array[$i]);
            $found += $Twitter->get_tweets('favorites', $twitter_id);
            $found += $Twitter->get_tweets('mine', $twitter_id);
        }
    }
    return $found;
}
Beispiel #2
0
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);
$filter = 'all';
if (isset($_GET['type']) && $_GET['type'] == 'mine') {
    $filter = 'type';
    $type = 'mine';
}
if (isset($_GET['type']) && $_GET['type'] == 'favorites') {