} ?> </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');
<?php global $bp; if ($_GET['reset'] == 'true') { delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_token'); delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_tokensecret'); delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_tokensecret_temp'); delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_token_temp'); delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_mention'); delete_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_synctoac'); } if (isset($_GET['code'])) { $buddystreamOAuth = new BuddyStreamOAuth(); $buddystreamOAuth->setAccessTokenUrl('https://foursquare.com/oauth2/access_token'); $buddystreamOAuth->setCallbackUrl($bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-foursquare'); $buddystreamOAuth->setParameters(array('redirect_uri' => $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/buddystream-networks/?network=foursquare', 'client_id' => get_site_option("buddystream_foursquare_consumer_key"), 'client_secret' => get_site_option("buddystream_foursquare_consumer_secret"), 'grant_type' => 'authorization_code', 'code' => $_GET['code'])); //get accesstoken and save it $accessToken = json_decode($buddystreamOAuth->accessToken(true)); update_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_token', $accessToken->access_token); update_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_synctoac', 1); //for other plugins do_action('buddystream_foursquare_activated'); } if ($_POST) { update_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_synctoac', $_POST['buddystream_foursquare_synctoac']); //achievements plugins update_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_achievements', $_POST['buddystream_foursquare_achievements']); $message = __('Settings saved', 'buddystream_foursquare'); } //put some options into variables $buddystream_foursquare_synctoac = get_user_meta($bp->loggedin_user->id, 'buddystream_foursquare_synctoac', 1);
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; }
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; }