예제 #1
0
/**
 * Post update to Twitter
 */
function buddystreamTwitterPostUpdate($content = "", $shortLink = "", $user_id = 0)
{
    global $bp;
    $buddyStreamFilters = new BuddyStreamFilters();
    //check for location
    $lat = null;
    $long = null;
    if (preg_match("/#location/i", $content)) {
        if (isset($_COOKIE["buddystream_location"])) {
            $arrLocation = explode("#", $_COOKIE["buddystream_location"]);
            $lat = $arrLocation[0];
            $long = $arrLocation[1];
        }
    }
    //strip out location tag
    $content = str_replace("#location", "", $content);
    $buddyStreamOAuth = new BuddyStreamOAuth();
    $buddyStreamOAuth->setRequestTokenUrl('https://api.twitter.com/oauth/request_token');
    $buddyStreamOAuth->setAccessTokenUrl('https://api.twitter.com/oauth/access_token');
    $buddyStreamOAuth->setAuthorizeUrl('https://api.twitter.com/oauth/authorize');
    $buddyStreamOAuth->setConsumerKey(get_site_option("tweetstream_consumer_key"));
    $buddyStreamOAuth->setConsumerSecret(get_site_option("tweetstream_consumer_secret"));
    $buddyStreamOAuth->setAccessToken(get_user_meta($bp->loggedin_user->id, 'tweetstream_token', 1));
    $buddyStreamOAuth->setAccessTokenSecret(get_user_meta($bp->loggedin_user->id, 'tweetstream_tokensecret', 1));
    $buddyStreamOAuth->setParameters(array('status' => $buddyStreamFilters->filterPostContent($content, $shortLink, 140), 'lat' => $lat, 'long' => $long));
    $buddyStreamOAuth->setRequestType("POST");
    $response = $buddyStreamOAuth->oAuthRequest('https://api.twitter.com/1.1/statuses/update.json');
    $response = json_decode($response);
    buddyStreamAddToImportLog($bp->loggedin_user->id, $response->id_str, 'twitter');
}
예제 #2
0
/**
 * Post update to Tumblr
 */
function buddystreamTumblrPostUpdate($content = "", $shortLink = "", $user_id = 0)
{
    //no location so remove tag
    $content = str_replace("#location", "", $content);
    global $bp;
    $buddyStreamFilters = new BuddyStreamFilters();
    //handle oauth calls
    $buddystreamOAuth = new BuddyStreamOAuth();
    $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_tumblr_consumer_key"));
    $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_tumblr_consumer_secret"));
    $buddystreamOAuth->setAccessToken(get_user_meta($bp->loggedin_user->id, 'buddystream_tumblr_token', 1));
    $buddystreamOAuth->setAccessTokenSecret(get_user_meta($bp->loggedin_user->id, 'buddystream_tumblr_tokensecret', 1));
    $buddystreamOAuth->setRequestType('POST');
    $buddystreamOAuth->setParameters(array('type' => 'text', 'body' => $buddyStreamFilters->filterPostContent($content, $shortLink)));
    $buddystreamTumblrBlogsOut = get_user_meta($bp->loggedin_user->id, 'buddystream_tumblr_blogs_out', 1);
    $buddystreamTumblrBlogsOut = explode(",", $buddystreamTumblrBlogsOut);
    foreach ($buddystreamTumblrBlogsOut as $blog) {
        $blog = urlencode('' . $blog . '.tumblr.com');
        $result = $buddystreamOAuth->oAuthRequest('http://api.tumblr.com/v2/blog/' . $blog . '/post');
        $result = json_decode($result);
        buddyStreamAddToImportLog($bp->loggedin_user->id, $result->response->id, 'tumblr');
    }
}
예제 #3
0
    </form>

<?php 
} else {
    echo '<h3>' . __('Google+ setup</h3>
                 You may setup you Google+ intergration over here.<br/>
                 Before you can begin using Google+ with this site you must authorize on Google+ by clicking the link below.', 'buddystream_googleplus') . '<br/><br/>';
    //oauth
    $buddystreamOAuth = new BuddyStreamOAuth();
    $buddystreamOAuth->setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken');
    $buddystreamOAuth->setAccessTokenUrl('https://www.google.com/accounts/OAuthGetAccessToken');
    $buddystreamOAuth->setAuthorizeUrl('https://www.google.com/accounts/OAuthAuthorizeToken');
    $buddystreamOAuth->setCallbackUrl($bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-networks/?network=googleplus');
    $buddystreamOAuth->setParameters(array('scope' => 'https://www.googleapis.com/auth/plus.me'));
    $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_googleplus_consumer_key"));
    $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_googleplus_consumer_secret"));
    //get requesttoken and save it for later use.
    $requestToken = $buddystreamOAuth->requestToken();
    $buddystreamOAuth->setRequestToken($requestToken['oauth_token']);
    $buddystreamOAuth->setRequestTokenSecret($requestToken['oauth_token_secret']);
    update_user_meta($bp->loggedin_user->id, 'buddystream_googleplus_token_temp', '' . urldecode($requestToken['oauth_token'] . ''));
    update_user_meta($bp->loggedin_user->id, 'buddystream_googleplus_tokensecret_temp', '' . $requestToken['oauth_token_secret'] . '');
    //get the redirect url for the user
    $redirectUrl = $buddystreamOAuth->getRedirectUrl();
    if ($redirectUrl) {
        echo '<a href="' . $redirectUrl . '" class="buddystream_authorize_button">' . __('Click here to start authorization', 'buddystream_googleplus') . '</a><br/><br/>';
    } else {
        _e('There is a problem with the authentication service at this moment please come back in a while.', 'buddystream_googleplus');
    }
}
예제 #4
0
 public function doImport()
 {
     global $wpdb;
     $buddyStreamLog = new BuddyStreamLog();
     $buddyStreamFilters = new BuddyStreamFilters();
     $itemCounter = 0;
     if (get_site_option("buddystream_tumblr_consumer_key")) {
         if (get_site_option('buddystream_tumblr_user_settings_syncbp') == 0) {
             $user_metas = $wpdb->get_results("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='buddystream_tumblr_token'");
             if ($user_metas) {
                 foreach ($user_metas as $user_meta) {
                     //check for daylimit
                     $limitReached = $buddyStreamFilters->limitReached('tumblr', $user_meta->user_id);
                     if (!$limitReached && get_user_meta($user_meta->user_id, 'buddystream_tumblr_synctoac', 1)) {
                         //Handle the OAuth requests
                         $buddystreamOAuth = new BuddyStreamOAuth();
                         $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_tumblr_consumer_key"));
                         $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_tumblr_consumer_secret"));
                         $buddystreamOAuth->setAccessToken(get_user_meta($user_meta->user_id, 'buddystream_tumblr_token', 1));
                         $buddystreamOAuth->setAccessTokenSecret(get_user_meta($user_meta->user_id, 'buddystream_tumblr_tokensecret', 1));
                         $buddystreamTumblrBlogsImport = get_user_meta($user_meta->user_id, 'buddystream_tumblr_blogs_import', 1);
                         $buddystreamTumblrBlogsImport = explode(",", $buddystreamTumblrBlogsImport);
                         foreach ($buddystreamTumblrBlogsImport as $blog) {
                             $blog = urlencode('' . $blog . '.tumblr.com');
                             $buddystreamOAuth->setParameters(array('base-hostname' => $blog, 'api_key' => get_site_option("buddystream_tumblr_consumer_key")));
                             $items = $buddystreamOAuth->oAuthRequest('http://api.tumblr.com/v2/blog/' . $blog . '/posts');
                             $items = json_decode($items);
                             $items = $items->response->posts;
                             if ($items) {
                                 //go through items
                                 foreach ($items as $item) {
                                     //check for daylimit
                                     $limitReached = $buddyStreamFilters->limitReached('tumblr', $user_meta->user_id);
                                     //get the title
                                     $title = "";
                                     if ($item->title) {
                                         $title = $item->title;
                                         $title = strip_tags($title);
                                         $title = trim($title);
                                         $title = "<strong>" . $title . "</strong> <br/>";
                                     }
                                     //get the image
                                     $image = "";
                                     if ($item->photos) {
                                         $caption = $item->caption;
                                         $caption = strip_tags($caption);
                                         $caption = trim($caption);
                                         $image = '<a href="' . $item->photos[0]->original_size->url . '" class="bs_lightbox"><img src="' . $item->photos[0]->alt_sizes[3]->url . '" alt="' . $caption . '"></a> ';
                                     }
                                     //get the body
                                     $body = $item->body . "" . $item->text . "" . $item->caption . "";
                                     $body = strip_tags($body);
                                     $body = trim($body);
                                     //combine all to content
                                     $content = "" . $title . "<br>" . $image . "" . $body . "";
                                     //check if good filter passes
                                     $goodFilters = get_site_option('buddystream_tumblr_filter');
                                     $goodFilter = $buddyStreamFilters->searchFilter($content, $goodFilters, false, true, true);
                                     //check if bad filter passes
                                     $badFilters = get_site_option('buddystream_tumblr_filterexplicit');
                                     $badFilter = $buddyStreamFilters->searchFilter($content, $badFilters, true);
                                     //no filters set so just import everything
                                     if (!get_site_option('buddystream_tumblr_filter')) {
                                         $goodFilter = true;
                                     }
                                     if (!get_site_option('buddystream_tumblr_filterexplicit')) {
                                         $badFilter = false;
                                     }
                                     if (!$limitReached && $goodFilter && !$badFilter) {
                                         //convert timestamp
                                         $timeStamp = strtotime($item->date);
                                         $returnCreate = buddystreamCreateActivity(array('user_id' => $user_meta->user_id, 'extension' => 'tumblr', 'type' => 'tumblr blogpost', 'content' => $content, 'item_id' => $item->id, 'raw_date' => gmdate('Y-m-d H:i:s', $timeStamp), 'actionlink' => trim($item->post_url . "")));
                                         if ($returnCreate) {
                                             $itemCounter++;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //add record to the log
     $buddyStreamLog->log("Tumblr imported " . $itemCounter . " items for " . count($user_metas) . " users.");
     //return number of items imported
     return $itemCounter;
 }
예제 #5
0
 public function doImport()
 {
     global $bp, $wpdb;
     $buddyStreamLog = new BuddyStreamLog();
     $buddyStreamFilters = new BuddyStreamFilters();
     $itemCounter = 0;
     if (get_site_option("buddystream_googleplus_consumer_key")) {
         if (get_site_option('buddystream_googleplus_user_settings_syncbp') == "on") {
             $user_metas = $wpdb->get_results("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='buddystream_googleplus_token'");
             if ($user_metas) {
                 foreach ($user_metas as $user_meta) {
                     //always start with import = true
                     $import = true;
                     //check for daylimit
                     $import = $buddyStreamFilters->limitReached('googleplus', $user_meta->user_id);
                     if (false === $import && get_user_meta($user_meta->user_id, 'buddystream_googleplus_synctoac', 1) == "1") {
                         //Handle the OAuth requests
                         $buddystreamOAuth = new BuddyStreamOAuth();
                         $buddystreamOAuth->setCallbackUrl($bp->root_domain);
                         $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_googleplus_consumer_key"));
                         $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_googleplus_consumer_secret"));
                         $buddystreamOAuth->setAccessToken(get_user_meta($user_meta->user_id, 'buddystream_googleplus_token', 1));
                         $buddystreamOAuth->setAccessTokenSecret(get_user_meta($user_meta->user_id, 'buddystream_googleplus_tokensecret', 1));
                         $items = $buddystreamOAuth->oAuthRequest('https://www.googleapis.com/plus/v1/people/me/activities/public');
                         $items = json_decode($items);
                         if (isset($items->items)) {
                             //go through items
                             foreach ($items->items as $item) {
                                 //check for daylimit
                                 $limitReached = $buddyStreamFilters->limitReached('googleplus', $user_meta->user_id);
                                 if (!$limitReached) {
                                     //pre-defined
                                     $content = "";
                                     $image = "";
                                     //create te correct content for the activity stream
                                     //hey we have some images
                                     if (isset($item->object->attachments)) {
                                         foreach ($item->object->attachments as $media) {
                                             $media->displayName = "";
                                             $media->url = "";
                                             if ($media->objectType == "article") {
                                                 $content .= $media->displayName . "<br>";
                                                 $content .= $media->content . "<br>";
                                                 $content .= '<a href="' . $media->url . '">' . __('visit link', 'buddystream_googleplus') . '</a>';
                                             } elseif ($media->objectType == "video") {
                                                 //transform the video url.
                                                 $videoUrl = $media->url;
                                                 $videoUrl = str_replace("http://www.youtube.com/v/", "", $videoUrl);
                                                 $videoUrlAray = explode("&", $videoUrl);
                                                 $videoId = $videoUrlAray[0];
                                                 $videoUrl = 'http://www.youtube.com/?v=' . $videoId;
                                                 $content .= $media->displayName . "<br>";
                                                 $content .= $media->content . "<br>";
                                                 $image .= '<a href="' . $videoUrl . '" id="' . $videoId . '" title="' . str_replace('"', '', $media->displayName) . '" class="bs_lightbox"><img src="' . $media->image->url . '">' . $media->displayName . '</a>';
                                             } else {
                                                 $image .= '<a href="' . $media->fullImage->url . '" title="' . str_replace('"', '', $media->displayName) . '" class="bs_lightbox"><img src="' . $media->image->url . '">' . $media->displayName . '</a>';
                                             }
                                         }
                                     } else {
                                         $content = $item->object->content;
                                     }
                                     //combine the images and content
                                     $content = $image . $content;
                                     //check if good filter passes
                                     $goodFilters = get_site_option('buddystream_googleplus_filter');
                                     $goodFilter = $buddyStreamFilters->searchFilter($content, $goodFilters, false, true, true);
                                     //check if bad filter passes
                                     $badFilters = get_site_option('buddystream_googleplus_filterexplicit');
                                     $badFilter = $buddyStreamFilters->searchFilter($content, $badFilters, true);
                                     //no filters set so just import everything
                                     if (!get_site_option('buddystream_googleplus_filter')) {
                                         $goodFilter = true;
                                     }
                                     if (!get_site_option('buddystream_googleplus_filterexplicit')) {
                                         $badFilter = false;
                                     }
                                     if ($goodFilter && !$badFilter) {
                                         $returnCreate = buddystreamCreateActivity(array('user_id' => $user_meta->user_id, 'extension' => 'googleplus', 'type' => 'google+ ' . $item->object->objectType, 'content' => $content, 'item_id' => 'googleplus_' . $item->id, 'raw_date' => gmdate('Y-m-d H:i:s', strtotime($item->published)), 'actionlink' => $item->url));
                                         if ($returnCreate) {
                                             $itemCounter++;
                                         }
                                     }
                                     unset($videoId, $content, $videoUrl, $image);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //add record to the log
     $buddyStreamLog->log("Google+ imported " . $itemCounter . " items.");
     //return number of items imported
     return $itemCounter;
 }
예제 #6
0
    ?>

    </form>

<?php 
} else {
    echo '<h3>' . __('LinkedIn setup</h3>
                 You may setup you linkedIn intergration over here.<br/>
                 Before you can begin using LinkedIn with this site you must authorize on LinkedIn by clicking the link below.', 'buddystream_linkedin') . '<br/><br/>';
    //oauth
    $buddystreamOAuth = new BuddyStreamOAuth();
    $buddystreamOAuth->setRequestTokenUrl('https://api.linkedin.com/uas/oauth/requestToken');
    $buddystreamOAuth->setAccessTokenUrl('https://api.linkedin.com/uas/oauth/accessToken');
    $buddystreamOAuth->setAuthorizeUrl('https://api.linkedin.com/uas/oauth/authorize');
    $buddystreamOAuth->setCallbackUrl($bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-networks/?network=linkedin');
    $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_linkedin_consumer_key"));
    $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_linkedin_consumer_secret"));
    //get requesttoken and save it for later use.
    $requestToken = $buddystreamOAuth->requestToken();
    $buddystreamOAuth->setRequestToken($requestToken['oauth_token']);
    $buddystreamOAuth->setRequestTokenSecret($requestToken['oauth_token_secret']);
    update_user_meta($bp->loggedin_user->id, 'buddystream_linkedin_token_temp', '' . $requestToken['oauth_token'] . '');
    update_user_meta($bp->loggedin_user->id, 'buddystream_linkedin_tokensecret_temp', '' . $requestToken['oauth_token_secret'] . '');
    //get the redirect url for the user
    //$redirectUrl = $buddystreamOAuth->getRedirectUrl();
    // $redirectUrl =  "https://www.linkedin.com/uas/oauth2/authorization?scope=rw_nus&response_type=code&client_id=".get_site_option("buddystream_linkedin_consumer_key")."&state=".uniqid()."&redirect_uri=" . $bp->loggedin_user->domain . BP_SETTINGS_SLUG . "/buddystream-networks/?network=linkedin";
    $redirectUrl = "https://www.linkedin.com/uas/oauth2/authorization?scope=w_share&response_type=code&client_id=" . get_site_option("buddystream_linkedin_consumer_key") . "&state=" . uniqid() . "&redirect_uri=" . $bp->loggedin_user->domain . BP_SETTINGS_SLUG . "/buddystream-networks/?network=linkedin";
    if ($redirectUrl) {
        echo '<a href="' . $redirectUrl . '" class="buddystream_authorize_button">' . __('Click here to start authorization', 'buddystream_linkedin') . '</a><br/><br/>';
    } else {
        _e('There is a problem with the authentication service at this moment please come back in a while.', 'buddystream_linkedin');
예제 #7
0
</a>
    <?php 
    }
    ?>
    </form>

<?php 
} else {
    echo __('<h3>Twitter setup</h3>You may setup you twitter intergration over here.<br/>Before you can begin using Twitter with this site you must authorize on Twitter by clicking the link below.', 'buddystream_twitter') . '<br/><br/>';
    //oauth
    $buddystreamOAuth = new BuddyStreamOAuth();
    $buddystreamOAuth->setRequestTokenUrl('https://api.twitter.com/oauth/request_token');
    $buddystreamOAuth->setAccessTokenUrl('https://api.twitter.com/oauth/access_token');
    $buddystreamOAuth->setAuthorizeUrl('https://api.twitter.com/oauth/authorize');
    $buddystreamOAuth->setCallbackUrl($bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-networks/?network=twitter');
    $buddystreamOAuth->setConsumerKey(get_site_option("tweetstream_consumer_key"));
    $buddystreamOAuth->setConsumerSecret(get_site_option("tweetstream_consumer_secret"));
    //get request token and save it for later use.
    $requestToken = $buddystreamOAuth->requestToken();
    $buddystreamOAuth->setRequestToken($requestToken['oauth_token']);
    $buddystreamOAuth->setRequestTokenSecret($requestToken['oauth_token_secret']);
    update_user_meta($bp->loggedin_user->id, 'tweetstream_token_temp', '' . $requestToken['oauth_token'] . '');
    update_user_meta($bp->loggedin_user->id, 'tweetstream_token_secret_temp', '' . $requestToken['oauth_token_secret'] . '');
    //get the redirect url for the user
    $redirectUrl = $buddystreamOAuth->getRedirectUrl();
    if ($redirectUrl) {
        echo '<a href="' . $redirectUrl . '" class="buddystream_authorize_button">' . __('Click here to start authorization', 'buddystream_twitter') . '</a><br/><br/>';
    } else {
        _e('There is a problem with the authentication service at this moment please come back in a while.', 'buddystream_twitter');
    }
}
예제 #8
0
    ?>

    </form>

<?php 
} else {
    echo '<h3>' . __('Tumblr setup', 'buddystream_tumblr') . '</h3>';
    echo __('You may setup you Tumblr intergration over here.<br/>
                 Before you can begin using Tumblr with this site you must authorize on Tumblr by clicking the link below.', 'buddystream_tumblr') . '<br/><br/>';
    //oauth
    $buddystreamOAuth = new BuddyStreamOAuth();
    $buddystreamOAuth->setRequestTokenUrl('http://www.tumblr.com/oauth/request_token');
    $buddystreamOAuth->setAccessTokenUrl('http://www.tumblr.com/oauth/access_token');
    $buddystreamOAuth->setAuthorizeUrl('http://www.tumblr.com/oauth/authorize');
    $buddystreamOAuth->setCallbackUrl($bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-networks/?network=tumblr');
    $buddystreamOAuth->setConsumerKey(get_site_option("buddystream_tumblr_consumer_key"));
    $buddystreamOAuth->setConsumerSecret(get_site_option("buddystream_tumblr_consumer_secret"));
    //get requesttoken and save it for later use.
    $requestToken = $buddystreamOAuth->requestToken();
    $buddystreamOAuth->setRequestToken($requestToken['oauth_token']);
    $buddystreamOAuth->setRequestTokenSecret($requestToken['oauth_token_secret']);
    update_user_meta($bp->loggedin_user->id, 'buddystream_tumblr_token_temp', '' . $requestToken['oauth_token'] . '');
    update_user_meta($bp->loggedin_user->id, 'buddystream_tumblr_tokensecret_temp', '' . $requestToken['oauth_token_secret'] . '');
    //get the redirect url for the user
    $redirectUrl = $buddystreamOAuth->getRedirectUrl();
    if ($redirectUrl) {
        echo '<a href="' . $redirectUrl . '" class="buddystream_authorize_button">' . __('Click here to start authorization', 'buddystream_tumblr') . '</a><br/><br/>';
    } else {
        _e('There is a problem with the authentication service at this moment please come back in a while.', 'buddystream_tumblr');
    }
}
예제 #9
0
 public function doImport()
 {
     global $bp, $wpdb;
     $buddyStreamLog = new BuddyStreamLog();
     $buddyStreamFilters = new BuddyStreamFilters();
     //item counter for in the logs
     $itemCounter = 0;
     if (get_site_option("tweetstream_consumer_key")) {
         if (get_site_option('tweetstream_user_settings_syncbp') == 0) {
             $user_metas = $wpdb->get_results("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='tweetstream_token'");
             if ($user_metas) {
                 foreach ($user_metas as $user_meta) {
                     //check for
                     $limitReached = $buddyStreamFilters->limitReached('twitter', $user_meta->user_id);
                     if (!$limitReached && get_user_meta($user_meta->user_id, 'tweetstream_synctoac', 1) && !get_user_meta($user_meta->user_id, 'buddystream_linkedin_reauth', 1)) {
                         //Handle the OAuth requests
                         $buddyStreamOAuth = new BuddyStreamOAuth();
                         $buddyStreamOAuth->setCallbackUrl($bp->root_domain);
                         $buddyStreamOAuth->setConsumerKey(get_site_option("tweetstream_consumer_key"));
                         $buddyStreamOAuth->setConsumerSecret(get_site_option("tweetstream_consumer_secret"));
                         $buddyStreamOAuth->setAccessToken(get_user_meta($user_meta->user_id, 'tweetstream_token', 1));
                         $buddyStreamOAuth->setAccessTokenSecret(get_user_meta($user_meta->user_id, 'tweetstream_tokensecret', 1));
                         //update the user Info
                         $twitter_settings = $buddyStreamOAuth->oAuthRequest('https://api.twitter.com/1.1/account/settings.json');
                         $twitter_settings = json_decode($twitter_settings);
                         $screenName = $twitter_settings->screen_name;
                         update_user_meta($user_meta->user_id, 'tweetstream_screenname', $screenName);
                         $twitter_account = $buddyStreamOAuth->oAuthRequest('https://api.twitter.com/1.1/users/show.json?screen_name=' . $screenName);
                         $twitter_account = json_decode($twitter_account);
                         update_user_meta($user_meta->user_id, 'gl_twitter_followers', $twitter_account->followers_count);
                         update_user_meta($user_meta->user_id, 'gl_twitter_following', $twitter_account->friends_count);
                         //update_user_meta($user_meta->user_id, 'description', $twitter_account->description);
                         //Hook to do something on user during import process
                         do_action('buddystream_import_twitter_user', $user_meta->user_id);
                         //get timeline
                         $items = $buddyStreamOAuth->oAuthRequest('https://api.twitter.com/1.1/statuses/user_timeline.json');
                         $items = json_decode($items);
                         if ($items->error) {
                             update_user_meta($user_meta->user_id, "buddystream_twitter_reauth", true);
                         }
                         if ($items && !$items->error) {
                             //go through tweets
                             foreach ($items as $tweet) {
                                 //check daylimit
                                 $limitReached = $buddyStreamFilters->limitReached('twitter', $user_meta->user_id);
                                 //check if good filter passes
                                 $goodFilters = get_site_option('tweetstream_filter');
                                 $goodFilter = $buddyStreamFilters->searchFilter($tweet->text, $goodFilters, false, true, true);
                                 //check if bad filter passes
                                 $badFilters = get_site_option('tweetstream_filterexplicit');
                                 $badFilter = $buddyStreamFilters->searchFilter($tweet->text, $badFilters, true);
                                 //no filters set so just import everything
                                 if (!get_site_option('tweetstream_filter')) {
                                     $goodFilter = true;
                                 }
                                 if (!get_site_option('tweetstream_filterexplicit')) {
                                     $badFilter = false;
                                 }
                                 //check if source filter passes
                                 $sourceFilter = $buddyStreamFilters->searchFilter($bp->root_domain, $tweet->source, true);
                                 if (!$limitReached && $goodFilter && !$badFilter && !$sourceFilter) {
                                     $content = '';
                                     if (isset($tweet->entities->media)) {
                                         foreach ($tweet->entities->media as $media) {
                                             $content .= '<a href="' . urldecode($media->media_url) . '" rel="lightbox" class="thickbox"><img src="' . $media->media_url . '"></a>';
                                         }
                                     }
                                     $content .= $tweet->text;
                                     $returnCreate = buddystreamCreateActivity(array('user_id' => $user_meta->user_id, 'extension' => 'twitter', 'type' => 'tweet', 'content' => $content, 'item_id' => buddystreamGetTweetId($tweet->id), 'raw_date' => gmdate('Y-m-d H:i:s', strtotime($tweet->created_at)), 'actionlink' => 'https://www.twitter.com/' . $screenName . '/status/' . buddystreamGetTweetId($tweet->id)));
                                     if ($returnCreate) {
                                         $itemCounter++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //add record to the log
     $buddyStreamLog->log("Twitter imported " . $itemCounter . " tweets for " . count($user_metas) . " users.");
     //return number of items imported
     return $itemCounter;
 }