Exemplo n.º 1
0
function tweetable_publish_tweet($post_id)
{
    $installed = get_option('tweetable_account_activated');
    if (get_option('tweetable_auto_tweet_posts') == '1' && $installed) {
        $post = get_post($post_id);
        if ($post->post_status == 'private' || $post->post_type == 'page') {
            return;
        }
        if ($post->post_date < $post->post_modified) {
            return;
        }
        $user_key = get_option('tweetable_access_token');
        $user_key_secret = get_option('tweetable_access_token_secret');
        $twitter = new Twitter_API(get_option('tweetable_app_key'), get_option('tweetable_app_key_secret'));
        $shortener = get_option('tweetable_url_shortener');
        $shortener_login = get_option('tweetable_shortener_login');
        $shortener_apikey = get_option('tweetable_shortener_apikey');
        $tweet_prefix = get_option('tweetable_auto_tweet_prefix');
        $googletags = get_option('tweetable_google_campaign_tags');
        $permalink = get_permalink($post_id);
        if ($googletags == '1') {
            $tags = '?utm_source=twitter&utm_medium=social&utm_campaign=' . urlencode($post->post_title);
            $permalink = urlencode($permalink . $tags);
        }
        $permalink = apply_filters('tweetable_autotweet_permalink', $permalink);
        $permalink = $twitter->shorten_url($permalink, $shortener, $shortener_apikey, $shortener_login);
        $title = $tweet_prefix . ' ' . $post->post_title;
        $title = apply_filters('tweetable_autotweet_title', $title);
        $tweet = $twitter->fit_tweet($title, $permalink);
        $tweet = apply_filters('tweetable_autotweet_tweet', $tweet);
        $update = $twitter->update_status($tweet, $user_key, $user_key_secret);
    }
}
Exemplo n.º 2
0
     $latest_tweet_new['user']['screen_name'] = (string) $latest->user->screen_name;
     $latest_tweet_new['user']['profile_image_url'] = (string) $latest->user->profile_image_url;
     $latest_tweet_new['user']['url'] = (string) $latest->user->url;
     $latest_tweet_new['user']['followers_count'] = (string) $latest->user->followers_count;
     $latest_tweet_new['user']['friends_count'] = (string) $latest->user->friends_count;
     $latest_tweet = array('tweet' => $latest_tweet_new, 'cache_time' => mktime());
     update_option('tweetable_latest_tweet', $latest_tweet);
     $date = date('F j, Y g:i', strtotime($latest_tweet['tweet']['created_at']));
     echo '<strong>Latest: </strong>' . $latest_tweet['tweet']['text'] . ' <em>' . $date . '</em>';
     break;
 case 'shorten-url':
     $theurl = rawurlencode($_POST['theurl']);
     $shortener = get_option('tweetable_url_shortener');
     $shortener_login = get_option('tweetable_shortener_login');
     $shortener_apikey = get_option('tweetable_shortener_apikey');
     $shorturl = $twitter->shorten_url($theurl, $shortener, $shortener_apikey, $shortener_login);
     echo $shorturl;
     break;
 case 'search-add':
     $new = stripslashes($_POST['thekeyword']);
     $searches = get_option('tweetable_saved_searches');
     //$searches[] = $new;
     array_unshift($searches, $new);
     update_option('tweetable_saved_searches', $searches);
     echo $new;
     break;
 case 'search-delete':
     $delete = stripslashes($_POST['thesearch']);
     $delete = explode('-', $delete);
     $delete = $delete[1];
     $searches = get_option('tweetable_saved_searches');