$client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Yandex developer applications page ' . 'https://oauth.yandex.com/client/new , create a new application ' . 'and in the line ' . $application_line . ' set the client_id to Application ID and client_secret with Application password. ' . 'The callback URL must be ' . $client->redirect_uri); } /* API permissions */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://login.yandex.ru/info?format=json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Yandex OAuth client results</title> </head> <body>
$client->debug_http = true; $client->server = 'Facebook'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_facebook.php'; $client->client_id = '134526290051121'; $application_line = __LINE__; $client->client_secret = '8aef0e23031a9964381d8035fdf966c4'; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Facebook Apps page https://developers.facebook.com/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to App ID/API Key and client_secret with App Secret'); } /* API permissions */ $client->scope = 'email,publish_actions,user_friends'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://graph.facebook.com/v2.3/me/friends', 'GET', array(), array('FailOnAccessError' => true), $user); /* if($success) { // Get Friends that use the same application $success = $client->CallAPI( 'https://graph.facebook.com/v2.3/me/friends', 'GET', array(), array('FailOnAccessError'=>true), $friends); } */ if ($success) { // Requires publish_actions permissions and your application needs to be submitted for review $values = array('message' => '', 'link' => 'http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html', 'description' => 'This post was submitted using this PHP OAuth API client class.', 'picture' => 'http://files.phpclasses.org/files/blog/package/7700/file/PHP%2BOAuth.png'); /* $success = $client->CallAPI(
$client->client_id = CLIENT_ID; $application_line = __LINE__; $client->client_secret = CLIENT_SECRET; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Google APIs console page ' . 'http://code.google.com/apis/console in the API access tab, ' . 'create a new client ID, and in the line ' . $application_line . ' set the client_id to Client ID and client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'the domain is valid and can be resolved by a public DNS.'); } /* API permissions */ $client->scope = SCOPE; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://www.googleapis.com/oauth2/v1/userinfo', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { // Now check if user exist with same email ID $sql = "SELECT COUNT(*) AS count from GoogleLogin where email = :email_id"; try { $stmt = $DB->prepare($sql); $stmt->bindValue(":email_id", $user->email); $stmt->execute(); $result = $stmt->fetchAll();
require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = 1; $client->debug_http = 1; $client->server = 'Tumblr'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_tumblr.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Tumblr Apps page http://www.tumblr.com/oauth/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Default callback URL must be ' . $client->redirect_uri); } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('http://api.tumblr.com/v2/user/info', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Tumblr OAuth client results</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head>
$client = new oauth_client_class(); $client->server = 'Google'; $client->offline = false; $client->debug = false; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/invite_gmail'; $client->client_id = 'googleClientID'; $client->client_secret = 'googleClientSecret'; $client->scope = 'https://www.google.com/m8/feeds/'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://www.google.com/m8/feeds/contacts/default/full?max-results=2500', 'GET', array(), array('FailOnAccessError' => true), $data); } } $success = $client->Finalize($success); } if ($client->exit) { $OP->ser("Something Happened", "<a href='" . $client->redirect_uri . "'>Try Again</a>"); } if ($success) { $firstName = get("fname"); $name = get("name", $who, false); $xml = new SimpleXMLElement($data); $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005'); $result = $xml->xpath('//gd:email'); foreach ($result as $title) { $email = $title->attributes()->address;
$client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to StockTwits new application page ' . 'http://stocktwits.com/developers/apps/new and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The site domain must have the same domain of ' . $client->redirect_uri); } /* API permissions */ $client->scope = 'read,watch_lists,publish_messages,publish_watch_lists,direct_messages,follow_users,follow_stocks'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://api.stocktwits.com/api/2/account/verify.json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>StockTwits OAuth client results</title> </head> <body>
$client->debug_http = true; $client->server = 'Misfit'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_misfit.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Misfit Apps page https://developers.misfit.com/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to App ID/API Key and client_secret with App Secret'); } /* API permissions */ $client->scope = 'email'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.misfitwearables.com/move/resource/v1/user/me/profile', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Misfit OAuth client results</title> </head> <body>
$client->debug_http = true; $client->server = 'Facebook'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_facebook.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Facebook Apps page https://developers.facebook.com/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to App ID/API Key and client_secret with App Secret'); } /* API permissions */ $client->scope = 'email,publish_actions,user_friends'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://graph.facebook.com/v2.3/me', 'GET', array(), array('FailOnAccessError' => true), $user); /* if($success) { // Get Friends that use the same application $success = $client->CallAPI( 'https://graph.facebook.com/v2.3/me/friends', 'GET', array(), array('FailOnAccessError'=>true), $friends); } */ if ($success) { // Requires publish_actions permissions and your application needs to be submitted for review $values = array('message' => '', 'link' => 'http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html', 'description' => 'This post was submitted using this PHP OAuth API client class.', 'picture' => 'http://files.phpclasses.org/files/blog/package/7700/file/PHP%2BOAuth.png'); $success = $client->CallAPI('https://graph.facebook.com/v2.3/me/feed', 'POST', $values, array('FailOnAccessError' => true), $post); }
$client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please register a new RunKeeper application in ' . 'http://runkeeper.com/partner/applications/register , and in the line ' . $application_line . ' set the client_id to Client ID and ' . 'client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'it is a secure URL (https://).'); } /* API permissions, empty is the default for this application */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://api.runkeeper.com/profile/', 'GET', array(), array('FailOnAccessError' => true, 'FollowRedirection' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>RunKeeper OAuth client results</title> </head> <body>
$client->debug = 0; $client->debug_http = 1; $client->server = 'Flickr'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_flickr.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Flickr Apps page http://www.flickr.com/services/apps/create/ , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Key and client_secret with Secret.'); } $client->scope = 'read'; // 'read', 'write' or 'delete' if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('http://api.flickr.com/services/rest/', 'GET', array('method' => 'flickr.test.login', 'format' => 'json', 'nojsoncallback' => '1'), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Flickr OAuth client results</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head>
require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = 1; $client->debug_http = 1; $client->server = 'Fitbit'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_fitbit.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Fitbit application registration page https://dev.fitbit.com/apps/new , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . ' Make sure this URL is ' . 'not in a private network and accessible to the Fitbit site.'; } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.fitbit.com/1/user/-/profile.json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Fitbit OAuth client results</title> </head> <body>
die; } // Define permisos de la API (si es necesario) if ($OAuth_Alcance != "") { $client->scope = $OAuth_Alcance; } if ($success = $client->Initialize()) { if ($success = $client->Process()) { // INICIO DEL PROCESAMIENTO POR SERVICIO // Google if ($OAuth_servicio == 'Google') { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://www.googleapis.com/oauth2/v1/userinfo', 'GET', array(), array('FailOnAccessError' => true), $user); } } // Facebook if ($OAuth_servicio == 'Facebook') { if (strlen($client->access_token)) { $success = $client->CallAPI('https://graph.facebook.com/me', 'GET', array(), array('FailOnAccessError' => true), $user); } } // LinkedIn if ($OAuth_servicio == 'LinkedIn') { if (strlen($client->access_token)) { $success = $client->CallAPI('http://api.linkedin.com/v1/people/~', 'GET', array('format' => 'json'), array('FailOnAccessError' => true), $user); } } // Instagram
$client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { /* * Requests just to get just the user details can be obtained * sending a request to the URL defined by the variable: * $client->access_token_response['id'] * * Other API requests need to be sent to the base URL defined by: * $client->access_token_response['instance_url'] */ $success = $client->CallAPI($client->access_token_response['id'], 'GET', array(), array('FailOnAccessError' => true, 'FollowRedirection' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Salesforce OAuth client results</title> </head> <body>
$client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Reddit preferences and apps page ' . 'https://ssl.reddit.com/prefs/apps , create a new application,' . ' and in the line ' . $application_line . ' set the client_id to' . ' application id below the title' . ' and client_secret with secret. ' . 'The callback URL must be ' . $client->redirect_uri); } /* API permissions */ $client->scope = 'identity'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://oauth.reddit.com/api/v1/me.json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Google OAuth client results</title> </head> <body>
$client->client_id = $linkedinApiKey; $application_line = __LINE__; $client->client_secret = $linkedinApiSecret; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to LinkedIn Apps page https://www.linkedin.com/secure/developer?newapp= , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . ' Make sure you enable the ' . 'necessary permissions to execute the API calls your application needs.'; } /* API permissions */ $client->scope = $linkedinScope; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('http://api.linkedin.com/v1/people/~:(id,email-address,first-name,last-name,location,picture-url,public-profile-url,formatted-name)', 'GET', array('format' => 'json'), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { $user_id = $db->checkUser($user); $_SESSION['loggedin_user_id'] = $user_id; $_SESSION['user'] = $user; } else { $_SESSION["err_msg"] = $client->error; } header("location:index.php");
public static function Dropbox($oTenant) { $bResult = false; $oUser = null; $bDropboxAllow = $oTenant->SocialDropboxAllow; $sDropboxId = $oTenant->SocialDropboxKey; $sDropboxSecret = $oTenant->SocialDropboxSecret; $sRedirectUrl = rtrim(\MailSo\Base\Http::SingletonInstance()->GetFullUrl(), '\\/ ') . '/?dropbox'; if (!strpos($sRedirectUrl, '://localhost')) { $sRedirectUrl = str_replace('http:', 'https:', $sRedirectUrl); } if ($bDropboxAllow) { require PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/http.php'; require PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/oauth_client.php'; $oClient = new \oauth_client_class(); $oClient->debug = self::$Debug; $oClient->debug_http = self::$Debug; $oClient->server = 'Dropbox2'; $oClient->redirect_uri = $sRedirectUrl; $oClient->client_id = $sDropboxId; $application_line = __LINE__; $oClient->client_secret = $sDropboxSecret; $oClient->configuration_file = PSEVEN_APP_ROOT_PATH . 'libraries/OAuthClient/' . $oClient->configuration_file; if (strlen($oClient->client_id) == 0 || strlen($oClient->client_secret) == 0) { $bResult = false; exit('Please go to Dropbox Apps page https://www.dropbox.com/developers/apps , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $oClient->redirect_uri) . ' Make sure this URL is ' . 'not in a private network and accessible to the Dropbox site.'; } if ($success = $oClient->Initialize()) { if ($success = $oClient->Process()) { if (strlen($oClient->access_token)) { $success = $oClient->CallAPI('https://api.dropbox.com/1/account/info', 'GET', array(), array('FailOnAccessError' => true), $oUser); } } $success = $oClient->Finalize($success); } if ($oClient->exit) { $bResult = false; exit; } if ($success && $oUser) { // if you need re-ask user for permission //$oClient->ResetAccessToken(); $aSocial = array('type' => 'dropbox', 'id' => $oUser->uid, 'name' => $oUser->display_name, 'email' => isset($oUser->email) ? $oUser->email : '', 'access_token' => $oClient->access_token); \CApi::Log('social_user_dropbox'); \CApi::LogObject($oUser); $bResult = $aSocial; } else { $bResult = false; $oClient->ResetAccessToken(); self::_socialError($oClient->error, 'dropbox'); } } return $bResult; }
function pumpio_fetchallcomments(&$a, $uid, $id) { $ckey = get_pconfig($uid, 'pumpio', 'consumer_key'); $csecret = get_pconfig($uid, 'pumpio', 'consumer_secret'); $otoken = get_pconfig($uid, 'pumpio', 'oauth_token'); $osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret'); $hostname = get_pconfig($uid, 'pumpio', 'host'); $username = get_pconfig($uid, "pumpio", "user"); logger("pumpio_fetchallcomments: completing comment for user " . $uid . " post id " . $id); $own_id = "https://" . $hostname . "/" . $username; $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); // Fetching the original post $r = q("SELECT `extid` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `extid` != '' LIMIT 1", dbesc($id), intval($uid)); if (!count($r)) { return false; } $url = $r[0]["extid"]; $client = new oauth_client_class(); $client->oauth_version = '1.0a'; $client->authorization_header = true; $client->url_parameters = false; $client->client_id = $ckey; $client->client_secret = $csecret; $client->access_token = $otoken; $client->access_token_secret = $osecret; logger("pumpio_fetchallcomments: fetching comment for user " . $uid . " url " . $url); if (pumpio_reachable($url)) { $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError' => true), $item); } else { $success = false; } if (!$success) { return; } if ($item->likes->totalItems != 0) { foreach ($item->likes->items as $post) { $like = new stdClass(); $like->object = new stdClass(); $like->object->id = $item->id; $like->actor = new stdClass(); $like->actor->displayName = $item->displayName; $like->actor->preferredUsername = $item->preferredUsername; $like->actor->url = $item->url; $like->actor->image = $item->image; $like->generator = new stdClass(); $like->generator->displayName = "pumpio"; pumpio_dolike($a, $uid, $self, $post, $own_id, false); } } if ($item->replies->totalItems == 0) { return; } foreach ($item->replies->items as $item) { if ($item->id == $id) { continue; } // Checking if the comment already exists - Two queries for speed issues $r = q("SELECT extid FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item->id), intval($uid)); if (count($r)) { continue; } $r = q("SELECT extid FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", dbesc($item->id), intval($uid)); if (count($r)) { continue; } $post = new stdClass(); $post->verb = "post"; $post->actor = $item->author; $post->published = $item->published; $post->received = $item->updated; $post->generator = new stdClass(); $post->generator->displayName = "pumpio"; // To-Do: Check for public post unset($item->author); unset($item->published); unset($item->updated); $post->object = $item; logger("pumpio_fetchallcomments: posting comment " . $post->object->id . " " . print_r($post, true)); pumpio_dopost($a, $client, $uid, $self, $post, $own_id, false); } }
$client->pin = OAUTH_PIN; } $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; /* API permission scopes * Separate scopes with a space, not with + */ $client->scope = 'r_fullprofile r_emailaddress'; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to LinkedIn Apps page https://www.linkedin.com/secure/developer?newapp= , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . ' Make sure you enable the ' . 'necessary permissions to execute the API calls your application needs.'; } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.linkedin.com/v1/people/~', 'GET', array('format' => 'json'), array('FailOnAccessError' => true), $user); /* * Use this if you just want to get the LinkedIn user email address */ /* $success = $client->CallAPI( 'https://api.linkedin.com/v1/people/~/email-address', 'GET', array( 'format'=>'json' ), array('FailOnAccessError'=>true), $email); */ } } $success = $client->Finalize($success); } if ($client->exit) {
require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $client->debug_http = true; $client->server = 'Bitbucket'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_bitbucket.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Bitbucket page to Manage Account ' . 'https://bitbucket.org/account/ , click on Integrated Applications, ' . 'then Add Consumer, and in the line ' . $application_line . ' set the client_id with Key and client_secret with Secret. ' . 'The URL must be ' . $client->redirect_uri); } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.bitbucket.org/1.0/user', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Bitbucket OAuth client results</title> </head> <body>
$client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please create a Bitly application in ' . 'https://bitly.com/a/oauth_apps , and in the line ' . $application_line . ' set the client_id to Client ID and ' . 'client_secret with Client Secret. ' . 'The callback URL must be ' . $client->redirect_uri . ' but make sure ' . 'it is a secure URL (https://).'); } /* API permissions, empty is the default for this application */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://api-ssl.bitly.com/v3/user/info', 'GET', array(), array('FailOnAccessError' => true, 'FollowRedirection' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Bitly OAuth client results</title> </head> <body>
require dirname(__FILE__) . '/../fb/http.php'; require dirname(__FILE__) . '/../fb/oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $client->debug_http = false; $client->server = 'Facebook'; $client->redirect_uri = 'http://v2.l4g.pl/lab/fbLoginOK.php'; $client->client_id = '134526290051121'; $application_line = __LINE__; $client->client_secret = '8aef0e23031a9964381d8035fdf966c4'; $client->scope = 'email,publish_actions,user_friends,user_posts'; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://graph.facebook.com/v2.3/me', 'GET', array(), array('FailOnAccessError' => true), $user); $client->CallAPI('https://graph.facebook.com/v2.5/naglowki/feed?fields=message,full_picture', 'GET', array(), array('FailOnAccessError' => true), $fanpageData); } } } $data = array(); $data['source'] = 'Facebook'; if ($success) { $data['status'] = 'OK'; if ($user->gender == 'male') { $user->genderPL = 'Mężczyzna'; } else { $user->genderPL = 'Kobieta'; } $data['userData'] = $user; $fanpageData = $fanpageData->data[0];
if (defined('OAUTH_PIN')) { $client->pin = OAUTH_PIN; } $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to imgur applications page https://api.imgur.com/oauth2/addclient , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Client ID and client_secret with Client Secret'); } /* API permissions */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.imgur.com/3/account/me', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>imgur OAuth client results</title> </head> <body>
require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $client->debug_http = true; $client->server = 'Withings'; $client->redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_withings.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Withings Apps page https://oauth.withings.com/en/partner/add , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to API key and client_secret with API secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . '.'; } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('http://wbsapi.withings.net/user?action=getbyuserid&userid=0', 'GET', array(), array('FailOnAccessError' => true, 'ResponseContentType' => 'application/json'), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Withings OAuth client results</title> </head> <body>
$api_key_line = __LINE__; $domain = ''; /* * API permission scopes */ $client->scope = ''; if (strlen($api_key) == 0 || strlen($domain) == 0) { die('Create an API key in https://admin.mailchimp.com/account/api/ ' . 'and set it in the line ' . $api_key_line . ' for instance "e33f7adf23e3e7beb89dc74b7985d2e7-us9". ' . ' The domain should be the end of the characters of the API key after - for instance "us9".'); } if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to MailChimp Apps page https://admin.mailchimp.com/account/oauth2/client/ , ' . 'register an application, and in the line ' . $application_line . ' set the client_id to client_id and client_secret with Client secret. ' . 'The Callback URL must be ' . $client->redirect_uri); } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://' . $domain . '.api.mailchimp.com/2.0/users/profile', 'GET', array('apikey' => $api_key), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
$client->debug = 1; $client->debug_http = 1; $client->server = 'Eventful'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_eventful.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; $application_key = ''; $account = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Eventful API request key page http://api.eventful.com/keys/new , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to oAuth Consumer Key and client_secret with oAuth Consumer Secret. ' . 'The Callback URL must be ' . $client->redirect_uri); } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('http://api.evdb.com/rest/users/get', 'GET', array('id' => $account, 'app_key' => $application_key), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Eventful OAuth client results</title> </head> <body>
'https://apis.live.net/v5.0/me', 'GET', array(), array('FailOnAccessError'=>true), $user); } } $success = $linkedin_login_client->Finalize($success); } */ if ($success = $linkedin_login_client->Initialize()) { if ($success = $linkedin_login_client->Process()) { if (strlen($linkedin_login_client->authorization_error)) { $linkedin_login_client->error = $linkedin_login_client->authorization_error; $success = false; } elseif (strlen($linkedin_login_client->access_token)) { $success = $linkedin_login_client->CallAPI('https://api.linkedin.com/v1/people/~', 'GET', array('format' => 'json'), array('FailOnAccessError' => true), $user); /* * Use this if you just want to get the LinkedIn user email address */ $success = $linkedin_login_client->CallAPI('https://api.linkedin.com/v1/people/~/email-address', 'GET', array('format' => 'json'), array('FailOnAccessError' => true), $linkedin_email); } } $success = $linkedin_login_client->Finalize($success); } cw_log_add('linkedin_login', array($linkedin_email, $user, $success)); if ($success) { //For logged in user, get details from linkedin using access token $linkedin_user_id = md5($linkedin_email); // $linkedin_uname = $user->firstName . ' ' . $user->lastName; $linkedin_user_firstname = $user->firstName; $linkedin_user_lastname = $user->lastName;
/** * Check querystring variables */ function the_champ_connect() { global $theChampLoginOptions; // verify email if (isset($_GET['SuperSocializerKey']) && ($verificationKey = trim(esc_attr($_GET['SuperSocializerKey']))) != '') { $users = get_users('meta_key=thechamp_key&meta_value=' . $verificationKey); if (count($users) > 0 && isset($users[0]->ID)) { delete_user_meta($users[0]->ID, 'thechamp_key'); // update password and send email $password = wp_generate_password(); wp_update_user(array('ID' => $users[0]->ID, 'user_pass' => $password)); the_champ_password_email($users[0]->ID, $password); wp_redirect(home_url() . '?SuperSocializerVerified=1'); die; } } // Instagram auth if (isset($_GET['SuperSocializerInstaToken']) && $_GET['SuperSocializerInstaToken'] != '') { $instaAuthUrl = 'https://api.instagram.com/v1/users/self?access_token=' . trim(esc_attr($_GET['SuperSocializerInstaToken'])); $response = wp_remote_get($instaAuthUrl, array('timeout' => 15)); if (!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']) { $body = json_decode(wp_remote_retrieve_body($response)); if (is_object($body->data) && isset($body->data) && isset($body->data->id)) { $redirection = isset($_GET['super_socializer_redirect_to']) && $_GET['super_socializer_redirect_to'] != '' ? esc_attr($_GET['super_socializer_redirect_to']) : ''; $response = the_champ_user_auth($body->data, 'instagram', $redirection); if (is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) { $redirectTo = esc_attr(the_champ_get_login_redirection_url($redirection, true)); } elseif (isset($response['message']) && $response['message'] == 'linked') { $redirectTo = $redirection . (strpos($redirection, '?') !== false ? '&' : '?') . 'linked=1'; } elseif (isset($response['message']) && $response['message'] == 'not linked') { $redirectTo = $redirection . (strpos($redirection, '?') !== false ? '&' : '?') . 'linked=0'; } elseif (isset($response['url']) && $response['url'] != '') { $redirectTo = $response['url']; } else { $redirectTo = esc_attr(the_champ_get_login_redirection_url($redirection)); } the_champ_close_login_popup($redirectTo); } } } // send request to Xing if (isset($_GET['SuperSocializerAuth']) && $_GET['SuperSocializerAuth'] == 'Xing') { session_start(); if (!isset($_GET['oauth_token']) && isset($_SESSION['OAUTH_ACCESS_TOKEN'])) { unset($_SESSION['OAUTH_ACCESS_TOKEN']); } if (isset($theChampLoginOptions['xing_ck']) && $theChampLoginOptions['xing_ck'] != '' && isset($theChampLoginOptions['xing_cs']) && $theChampLoginOptions['xing_cs'] != '') { $xingClient = new oauth_client_class(); $xingClient->debug = 0; $xingClient->debug_http = 1; $xingClient->server = 'XING'; $xingClient->redirect_uri = site_url() . '/index.php?SuperSocializerAuth=Xing&super_socializer_redirect_to=' . esc_attr(str_replace(array('http://', 'https://'), '', urldecode($_GET['super_socializer_redirect_to']))); $xingClient->client_id = $theChampLoginOptions['xing_ck']; $xingClient->client_secret = $theChampLoginOptions['xing_cs']; if ($success = $xingClient->Initialize()) { if ($success = $xingClient->Process()) { if (strlen($xingClient->access_token)) { $success = $xingClient->CallAPI('https://api.xing.com/v1/users/me', 'GET', array(), array('FailOnAccessError' => true), $xingResponse); } } $success = $xingClient->Finalize($success); } if ($xingClient->exit) { die('exit'); } if ($success) { if (isset($xingResponse->users) && is_array($xingResponse->users) && isset($xingResponse->users[0]->id)) { $xingRedirect = the_champ_get_http() . esc_attr($_GET['super_socializer_redirect_to']); $response = the_champ_user_auth($xingResponse->users[0], 'xing', $xingRedirect); if (is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) { $redirectTo = esc_attr(the_champ_get_login_redirection_url($xingRedirect, true)); } elseif (isset($response['message']) && $response['message'] == 'linked') { $redirectTo = $xingRedirect . (strpos($xingRedirect, '?') !== false ? '&' : '?') . 'linked=1'; } elseif (isset($response['message']) && $response['message'] == 'not linked') { $redirectTo = $xingRedirect . (strpos($xingRedirect, '?') !== false ? '&' : '?') . 'linked=0'; } elseif (isset($response['url']) && $response['url'] != '') { $redirectTo = $response['url']; } else { $redirectTo = esc_attr(the_champ_get_login_redirection_url($xingRedirect)); } the_champ_close_login_popup($redirectTo); } } else { echo 'Error:' . $xingClient->error; die; } } } // send request to twitter if (isset($_GET['SuperSocializerAuth']) && $_GET['SuperSocializerAuth'] == 'Twitter') { if (isset($theChampLoginOptions['twitter_key']) && $theChampLoginOptions['twitter_key'] != '' && isset($theChampLoginOptions['twitter_secret']) && $theChampLoginOptions['twitter_secret'] != '') { /* Build TwitterOAuth object with client credentials. */ $connection = new TwitterOAuth($theChampLoginOptions['twitter_key'], $theChampLoginOptions['twitter_secret']); /* Get temporary credentials. */ $requestToken = $connection->getRequestToken(site_url() . '/index.php'); if ($connection->http_code == 200) { // generate unique ID $uniqueId = mt_rand(); // save oauth token and secret in db temporarily update_user_meta($uniqueId, 'thechamp_twitter_oauthtoken', $requestToken['oauth_token']); update_user_meta($uniqueId, 'thechamp_twitter_oauthtokensecret', $requestToken['oauth_token_secret']); if (isset($_GET['super_socializer_redirect_to']) && $_GET['super_socializer_redirect_to'] != '') { update_user_meta($uniqueId, 'thechamp_twitter_redirect', esc_attr($_GET['super_socializer_redirect_to'])); } wp_redirect($connection->getAuthorizeURL($requestToken['oauth_token'])); die; } else { ?> <div style="width: 500px; margin: 0 auto"> <ol> <li><?php echo sprintf(__('Enter exactly the following url in <strong>Website</strong> and <strong>Callback Url</strong> options in your Twitter app (see step 3 %s)', 'Super-Socializer'), '<a target="_blank" href="http://support.heateor.com/how-to-get-twitter-api-key-and-secret/">here</a>'); ?> <br/> <?php echo site_url(); ?> </li> <li><?php _e('Make sure cURL is enabled at your website server. You may need to contact the server administrator of your website to verify this', 'Super-Socializer'); ?> </li> </ol> </div> <?php die; } } } // twitter authentication if (isset($_REQUEST['oauth_token'])) { global $wpdb; $uniqueId = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'thechamp_twitter_oauthtoken' and meta_value = %s", $_REQUEST['oauth_token'])); $oauthTokenSecret = get_user_meta($uniqueId, 'thechamp_twitter_oauthtokensecret', true); // twitter redirect url $twitterRedirectUrl = get_user_meta($uniqueId, 'thechamp_twitter_redirect', true); if (empty($uniqueId) || $oauthTokenSecret == '') { // invalid request wp_redirect(site_url()); die; } $connection = new TwitterOAuth($theChampLoginOptions['twitter_key'], $theChampLoginOptions['twitter_secret'], $_REQUEST['oauth_token'], $oauthTokenSecret); /* Request access tokens from twitter */ $accessToken = $connection->getAccessToken($_REQUEST['oauth_verifier']); /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth($theChampLoginOptions['twitter_key'], $theChampLoginOptions['twitter_secret'], $accessToken['oauth_token'], $accessToken['oauth_token_secret']); $content = $connection->get('account/verify_credentials'); // delete temporary data delete_user_meta($uniqueId, 'thechamp_twitter_oauthtokensecret'); delete_user_meta($uniqueId, 'thechamp_twitter_oauthtoken'); delete_user_meta($uniqueId, 'thechamp_twitter_redirect'); if (is_object($content) && isset($content->id)) { $response = the_champ_user_auth($content, 'twitter', $twitterRedirectUrl); if (is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')) { $redirectTo = esc_attr(the_champ_get_login_redirection_url($twitterRedirectUrl, true)); } elseif (isset($response['message']) && $response['message'] == 'linked') { $redirectTo = $twitterRedirectUrl . (strpos($twitterRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1'; } elseif (isset($response['message']) && $response['message'] == 'not linked') { $redirectTo = $twitterRedirectUrl . (strpos($twitterRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0'; } elseif (isset($response['url']) && $response['url'] != '') { $redirectTo = $response['url']; } else { $redirectTo = esc_attr(the_champ_get_login_redirection_url($twitterRedirectUrl)); } the_champ_close_login_popup($redirectTo); } } }
// 37Signals $client->client_id = '68a354455ac2e3dacbce2f3ae5fd3fd018869e95'; $client->client_secret = '4a4be253ce94b861a1829db946120be48b2563fe'; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to 37Signals Integrate new application page ' . 'https://integrate.37signals.com/apps/new and in the line ' . $application_line . ' set the client_id to Client ID and client_secret with Client secret. ' . 'The site domain must have the same domain of ' . $client->redirect_uri); } /* API permissions */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->authorization_error)) { $client->error = $client->authorization_error; $success = false; } elseif (strlen($client->access_token)) { $success = $client->CallAPI('https://launchpad.37signals.com/authorization.json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>37Signals OAuth client results</title> </head> <body>
require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = 1; $client->debug_http = 1; $client->server = 'Yahoo'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_yahoo.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Yahoo Apps page https://developer.apps.yahoo.com/wsregapp/ , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Consumer key and client_secret with Consumer secret. ' . 'The Callback URL must be ' . $client->redirect_uri) . ' Make sure you enable the ' . 'necessary permissions to execute the API calls your application needs.'; } if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('http://query.yahooapis.com/v1/yql', 'GET', array('q' => 'select * from social.profile where guid=me', 'format' => 'json'), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Yahoo OAuth client results</title> </head> <body>
$client->debug_http = true; $client->server = 'Vimeo'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_vimeo.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please go to Vimeo Apps page https://developer.vimeo.com/apps/new , ' . 'create an application, and in the line ' . $application_line . ' set the client_id to Client Identifier and client_secret with Client Secret'); } /* API permissions */ $client->scope = ''; if ($success = $client->Initialize()) { if ($success = $client->Process()) { if (strlen($client->access_token)) { $success = $client->CallAPI('https://api.vimeo.com/me/?format=json', 'GET', array(), array('FailOnAccessError' => true), $user); } } $success = $client->Finalize($success); } if ($client->exit) { exit; } if ($success) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Vimeo OAuth client results</title> </head> <body>