function Finalize($success) { if ($this->opened_file) { fclose($this->opened_file); $this->opened_file = false; } return parent::Finalize($success); }
<?php /* * login_with_yandex.php * * @(#) $Id: login_with_yandex.php,v 1.1 2014/08/26 03:46:11 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'Yandex'; $client->debug = true; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_yandex.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 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;
// retreive information from user based on scope/permission define("SCOPE", 'https://www.googleapis.com/auth/userinfo.email ' . 'https://www.googleapis.com/auth/userinfo.profile'); /* logout both from Google and your site **/ define("LOGOUT_URL", "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=" . urlencode("http://localhost/TOMO2Project_Materialize/Card-2/card-2.php")); ?> /* Add login URL in index.php */ <a class="btn btn-block btn-social btn-google-plus" href="index.php"> <i class="fa fa-google-plus"></i> Login with Google </a> <?php require 'http.php'; require 'oauth_client.php'; require 'config.php'; $client = new oauth_client_class(); // set the offline access only if you need to call an API // when the user is not present and the token may expire $client->offline = FALSE; $client->debug = false; $client->debug_http = true; $client->redirect_uri = REDIRECT_URL; $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;
/** * 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); } } }
<?php /* * login_with_eventful.php * * @(#) $Id: login_with_eventful.php,v 1.3 2014/07/29 22:18:45 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $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); }
<?php /* * login_with_withings.php * * @(#) $Id: login_with_withings.php,v 1.1 2014/01/26 05:07:10 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; 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);
<?php 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;
<?php /* * login_with_runkeeper.php * * @(#) $Id: login_with_runkeeper.php,v 1.1 2014/05/15 08:29:50 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'RunKeeper'; $client->debug = false; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_runkeeper.php'; $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;
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; }
<?php /* * login_with_flickr.php * * @(#) $Id: login_with_flickr.php,v 1.4 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $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); }
<?php /* * login_with_fitbit.php * * @(#) $Id: login_with_fitbit.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; 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);
* OAuth_solicitado: Indica el tipo de servicio OAuth que debe ser llamado. * Permite por ahora los valores (22): Google, Facebook, LinkedIn, Instagram, Dropbox, Microsoft (Live), Flickr, Twitter, Foursquare, XING, Salesforce, Bitbucket, Yahoo, Box, Disqus, Eventful, SurveyMonkey, RightSignature, Fitbit, ScoopIt, Tumblr, StockTwits Salida: Redireccion del usuario a la pagina de login del proveedor de autenticacion , quien a su vez redireccionara al usuario segun el resultado Ver tambien: <Iniciar_login> */ if (@$PCO_WSId == "autenticacion_oauth") { require 'inc/http/http.php'; // Incluye funciones del cliente HTTP para conexiones desde PHP require 'inc/oauth/oauth_client.php'; // Incluye las librerias del modulo OAuth 1.0 y 2.0 // Inicia la conexion correspondiente $client = new oauth_client_class(); // Define el servicio a llamar segun el recibido $OAuth_servicio = $OAuthSrv; // Google if ($OAuth_servicio == 'Google') { $OAuth_URIRedireccion = $APIGoogle_RedirectUri; $OAuth_IDCliente = $APIGoogle_ClientId; $OAuth_SecretoCliente = $APIGoogle_ClientSecret; $OAuth_Mensaje = "Vaya a APIs de Google http://code.google.com/apis/console y cree un nuevo ID de cliente, Secreto y URI de redireccion."; $OAuth_Alcance = 'https://www.googleapis.com/auth/userinfo.email ' . 'https://www.googleapis.com/auth/userinfo.profile'; $OAuth_Depuracion = false; $OAuth_DepuracionHttp = true; $OAuth_Offline = false; } // Facebook if ($OAuth_servicio == 'Facebook') {
<?php /* * login_with_salesforce.php * * @(#) $Id: login_with_salesforce.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'Salesforce'; $client->debug = true; $client->debug_http = true; $client->redirect_uri = 'https://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_salesforce.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) { die('Please login with your Salesforce developer account, click on the' . ' Setup link, then click on the Develop link, then click on the ' . 'Remote Access link, create a new connected app, 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 . ' 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;
<?php /* * login_with_reddit.php * * @(#) $Id: login_with_reddit.php,v 1.1 2014/01/11 12:07:18 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'Reddit'; // set the offline access only if you need to call an API // when the user is not present and the token may expire $client->offline = true; $client->debug = false; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_reddit.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 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()) {
<?php /* * login_with_stocktwits.php * * @(#) $Id: login_with_stocktwits.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'StockTwits'; $client->debug = true; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_stocktwits.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 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;
<?php /* * login_with_bitly.php * * @(#) $Id: login_with_bitly.php,v 1.1 2014/05/15 04:06:17 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = 'Bitly'; $client->debug = false; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_bitly.php'; $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;
<?php /* * login_with_bitbucket.php * * @(#) $Id: login_with_bitbucket.php,v 1.2 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; 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);
<?php /* * login_with_imgur.php * * @(#) $Id: login_with_imgur.php,v 1.2 2014/11/14 10:37:51 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $client->debug_http = true; $client->server = 'imgur'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_imgur.php'; /* * Uncomment the next line if you want to use * the pin based authorization flow */ // $client->redirect_uri = 'oob'; /* * Was this script included defining the pin the * user entered to authorize the API access? */ if (defined('OAUTH_PIN')) { $client->pin = OAUTH_PIN; } $client->client_id = '';
<?php /* * login_with_misfit.php * * @(#) $Id: login_with_misfit.php,v 1.1 2015/03/12 09:22:00 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $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);
<?php /* * login_with_mailchimp.php * * @(#) $Id: login_with_mailchimp.php,v 1.1 2014/12/05 05:09:11 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $client->debug_http = true; $client->server = 'MailChimp'; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_mailchimp.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; $api_key = ''; $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".'); }
<?php /* * login_with_tumblr.php * * @(#) $Id: login_with_tumblr.php,v 1.3 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; 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);
<?php if (empty($customer_id)) { $linkedin_redirect_url = $http_location . '/index.php?target=login_with_linkedin'; //include linkedin api files cw_include('addons/linkedin_login/include/lib/http.php'); cw_include('addons/linkedin_login/include/lib/oauth_client.php'); $linkedin_login_client = new oauth_client_class(); $linkedin_login_client->server = 'LinkedIn'; $linkedin_login_client->debug = 0; $linkedin_login_client->redirect_uri = $linkedin_redirect_url; $linkedin_login_client->client_id = $config['linkedin_login']['linkedin_login_key']; $application_line = __LINE__; $linkedin_login_client->client_secret = $config['linkedin_login']['linkedin_login_secret']; $linkedin_login_info =& cw_session_register('linkedin_login_info'); $linkedin_login_client->scope = 'r_fullprofile r_emailaddress'; /* 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://apis.live.net/v5.0/me', 'GET', array(), array('FailOnAccessError'=>true), $user); } }
<?php \Fr\LS::init(); include "{$docRoot}/inc/oauth/http.php"; include "{$docRoot}/inc/oauth/oauth_client.php"; $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);
<?php /* * login_with_basecamp.php * * @(#) $Id: login_with_37signals.php,v 1.1 2014/03/17 09:45:08 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->server = '37Signals'; $client->debug = false; $client->debug_http = true; $client->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . dirname(strtok($_SERVER['REQUEST_URI'], '?')) . '/login_with_37signals.php'; $client->client_id = ''; $application_line = __LINE__; $client->client_secret = ''; // 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()) {
<?php /* * login_with_facebook.php * * @(#) $Id: login_with_facebook.php,v 1.4 2015/04/08 23:28:52 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = false; $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);
<?php session_start(); include_once "config.php"; include_once "includes/db.php"; include_once "LinkedIn/http.php"; include_once "LinkedIn/oauth_client.php"; //db class instance $db = new DB(); if (isset($_GET["oauth_problem"]) && $_GET["oauth_problem"] != "") { // in case if user cancel the login. redirect back to home page. $_SESSION["err_msg"] = $_GET["oauth_problem"]; header("location:index.php"); exit; } $client = new oauth_client_class(); $client->debug = false; $client->debug_http = true; $client->redirect_uri = $callbackURL; $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)) {
<?php /* * test_oauth_client.php * * @(#) $Id: test_oauth_client.php,v 1.5 2013/07/31 11:48:04 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; /* Create the OAuth authentication client class */ $client = new oauth_client_class(); /* * Set to true if you want to make the class dump * debug information to PHP error log */ $client->debug = true; /* * Set to true if you want to make the class also dump * debug output of the HTTP requests it sends. */ $client->debug_http = false; /* OAuth server type name * Setting this variable to one of the built-in supported OAuth servers * will make the class automatically set all parameters specific of that * type of server. * * Currently, built-in supported types are: Facebook, github, Google,
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); } }
<?php /* * login_with_yahoo.php * * @(#) $Id: login_with_yahoo.php,v 1.1 2012/10/05 09:23:25 mlemos Exp $ * */ require 'http.php'; 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;
<?php /* * login_with_vimeo.php * * @(#) $Id: login_with_vimeo.php,v 1.1 2014/04/11 10:25:46 mlemos Exp $ * */ /* * Get the http.php file from http://www.phpclasses.org/httpclient */ require 'http.php'; require 'oauth_client.php'; $client = new oauth_client_class(); $client->debug = true; $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);