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
require_once '../../../wp-load.php';
require_once 'mh_twitter_class.php';
if (!empty($_POST)) {
    $user_key = get_option('tweetable_access_token');
    $user_key_secret = get_option('tweetable_access_token_secret');
    $twitter_user = get_option('tweetable_twitter_user');
    $twitter = new Twitter_API(get_option('tweetable_app_key'), get_option('tweetable_app_key_secret'));
    switch ($_POST['do']) {
        case 'update-status':
            if ($_POST['token'] != md5($user_key)) {
                exit("I don't think so, hacker...\n");
            }
            $status = stripslashes($_POST['tweet']);
            $in_reply_to_status = $_POST['in_reply_to_status'];
            $latest = $twitter->update_status($status, $user_key, $user_key_secret, $in_reply_to_status);
            $latest_tweet_new['created_at'] = (string) $latest->created_at;
            $latest_tweet_new['id'] = (string) $latest->id;
            $latest_tweet_new['text'] = (string) $latest->text;
            $latest_tweet_new['source'] = (string) $latest->source;
            $latest_tweet_new['in_reply_to_status_id'] = (string) $latest->in_reply_to_status_id;
            $latest_tweet_new['in_reply_to_user_id'] = (string) $latest->in_reply_to_user_id;
            $latest_tweet_new['favorited'] = (string) $latest->favorited;
            $latest_tweet_new['in_reply_to_screen_name'] = (string) $latest->in_reply_to_screen_name;
            $latest_tweet_new['user']['id'] = (string) $latest->user->id;
            $latest_tweet_new['user']['name'] = (string) $latest->user->name;
            $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;