public function actionDefault() { $google_config = NEnvironment::getConfig()->google; require_once LIBS_DIR . '/google-api-php-client/src/apiClient.php'; require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiOauth2Service.php'; require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiAnalyticsService.php'; $client = new apiClient(); $client->setApplicationName('Google+ PHP Starter Application'); // Visit https://code.google.com/apis/console?api=plus to generate your // client id, client secret, and to register your redirect uri. // $client->setClientId( $google_config['client_id'] ); // $client->setClientSecret( $google_config['client_secret'] ); $client->setRedirectUri($google_config['redirect_url']); // $client->setDeveloperKey('AIzaSyCrViGDrmXAiLsQAoW1aOzkHddH9gHYzzs'); // [8] => Array // ( // [title] => www.propagacnepredmety.sk // [entryid] => http://www.google.com/analytics/feeds/accounts/ga:43556790 // [accountId] => 17205615 // [accountName] => www.vizion.sk // [profileId] => 43556790 // [webPropertyId] => UA-17205615-3 // [tableId] => ga:43556790 // ) $ga = new apiAnalyticsService($client); if (isset($_GET['code'])) { $ga->authenticate(); $_SESSION['token'] = $client->getAccessToken(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } if (isset($_SESSION['token'])) { $client->setAccessToken($_SESSION['token']); } if ($client->getAccessToken()) { $activities = $plus->activities->listActivities('me', 'public'); print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>'; // The access token may have been updated. $_SESSION['token'] = $client->getAccessToken(); } else { $authUrl = $client->createAuthUrl(); print "<a class='login' href='{$authUrl}'>Connect Me!</a>"; } // $_SESSION['token'] = $client->getAccessToken(); $data = $ga->data_ga; $d = $data->get('17205615', date('Y-m-d', time() - 60 * 60 * 24 * 40), date('Y-m-d', time() - 60 * 60 * 24 * 1), 'ga:visits,ga:pageviews'); print_r($d); exit; }
public function index() { $this->id = "content"; $this->template = "login/login.tpl"; $this->layout = "common/layout-empty"; if (Registry::get('username')) { header("Location: search.php"); exit; } $request = Registry::get('request'); $session = Registry::get('session'); $db = Registry::get('db'); $this->load->model('user/auth'); $this->load->model('user/user'); $this->load->model('user/prefs'); $this->load->model('domain/domain'); $this->load->model('folder/folder'); if (ENABLE_SAAS == 1) { $this->load->model('saas/ldap'); $this->load->model('saas/customer'); } $this->data['title'] = $this->data['text_login']; $this->data['title_prefix'] = TITLE_PREFIX; $this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count(); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) { if ($this->model_user_auth->checkLogin($this->request->post['username'], $_POST['password']) == 1) { if ($session->get("ga_block") == 1) { header("Location: " . SITE_URL . "index.php?route=login/ga"); exit; } else { $this->model_user_prefs->get_user_preferences($session->get('username')); if (ENABLE_SAAS == 1) { $this->model_saas_customer->online($session->get('email')); } LOGGER('logged in'); if (isAdminUser() == 1) { header("Location: " . SITE_URL . "index.php?route=health/health"); exit; } header("Location: " . SITE_URL . "search.php"); exit; } } else { $this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']); $this->data['failed_login_count']++; } $this->data['x'] = $this->data['text_invalid_email_or_password']; } if (ENABLE_GOOGLE_LOGIN == 1) { $client = new apiClient(); $client->setApplicationName(GOOGLE_APPLICATION_NAME); $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://mail.google.com/')); $client->setClientId(GOOGLE_CLIENT_ID); $client->setClientSecret(GOOGLE_CLIENT_SECRET); $client->setRedirectUri(GOOGLE_REDIRECT_URL); $client->setDeveloperKey(GOOGLE_DEVELOPER_KEY); $this->data['auth_url'] = $client->createAuthUrl(); } $this->render(); }
<?php require_once 'src/apiClient.php'; require_once 'src/contrib/apiPlusService.php'; session_start(); $client = new apiClient(); $client->setApplicationName("Kindle Reader"); $client->setScopes(array('https://www.google.com/reader/api')); if (isset($_REQUEST['logout'])) { unset($_SESSION['access_token']); } if (isset($_GET['code'])) { $client->authenticate(); $_SESSION['access_token'] = $client->getAccessToken(); $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); } if (isset($_SESSION['access_token'])) { $client->setAccessToken($_SESSION['access_token']); } if ($client->getAccessToken()) { $_SESSION['access_token'] = $client->getAccessToken(); header('Location: sender.php'); } else { $status = "Logged Out"; $authUrl = $client->createAuthUrl(); header('Location: ' . $authUrl); }
public function index() { session_start(); $client = new apiClient(); $redirectUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $client->setApplicationName('PHP, YouTube, OAuth2, and CodeIgniter Example'); $client->setClientId(CLIENT_ID); $client->setClientSecret(CLIENT_SECRET); $client->setRedirectUri($redirectUri); $client->setDeveloperKey(DEVELOPER_KEY); new apiPlusService($client); // Sets the OAuth2 scope. $this->load->library('youtube', array('apikey' => YOUTUBE_API_KEY)); // This example doesn't require authentication: // header("Content-type: text/plain"); // echo "Here is the output:\n"; // echo $this->youtube->getKeywordVideoFeed('pac man'); if (isset($_GET['code'])) { $client->authenticate(); $_SESSION['token'] = $client->getAccessToken(); header("Location: {$redirectUri}"); } if (isset($_SESSION['token'])) { $client->setAccessToken($_SESSION['token']); } if (!$client->getAccessToken()) { $authUrl = $client->createAuthUrl(); echo "<a class='login' href='{$authUrl}'>Connect Me!</a>"; } else { // The access token may have been updated lazily. $_SESSION['token'] = $client->getAccessToken(); header("Content-type: text/plain"); $accessToken = json_decode($_SESSION['token'])->access_token; echo "Here is the output:\n"; echo $this->youtube->getUserUploads('default', array('access_token' => $accessToken, 'prettyprint' => 'true')); } }
require_once 'includes/google-api-php-client/apiClient.php'; require_once 'includes/google-api-php-client/contrib/apiOauth2Service.php'; /******Google API Connection With My APP**************/ $client = new apiClient(); //$client->setApplicationName("TheASP"); $client->setClientId($client_id); $client->setClientSecret($client_secret); $client->setDeveloperKey($api_key); $client->setRedirectUri($redirect_url); $client->setApprovalPrompt(false); $oauth2 = new apiOauth2Service($client); ?> <!--******Printing The Login URL*************--> <a href="<?php echo $client->createAuthUrl(); ?> " class="googleLoginButton" title="Login With Google">Sign in with Google</a> <!--******Printing The Login URL*************--> <a href="collectUserDataTwitter.php" class="twitterLoginButton" title="Login With Twitter">Sign in with Twitter</a> </div> <p class="note">This Websites Uses The PHP APIS Of <a href="https://developers.facebook.com/docs/reference/php" target="_new">Facebook</a> And <a href="https://developers.google.com/api-client-library/php/start/get_started" target="_new">Google</a> And <a href="http://wwwtwitteroauth.com" target="_new">Twitter</a> To Create The Login System.</p> <footer> <h2><i>Author:</i><a href="http://www.vipinkhushu.com"> Vipin Khushu </a> | RAPL IND.( vipinkhushu[at]hotmail.com )</h2> <a class="tzine" href="http://www.github.com/vipinkhushu">Star And Fork This Project <i><b>Github</b></i></a> </footer> </body>
function gplus_init_auth_url() { global $authUrl; gplus_load(); try { $client = new apiClient(); $plus = new apiOauth2Service($client); $authUrl = $client->createAuthUrl(); } catch (Exception $e) { $authUrl = ''; } }
public function index() { $this->load->language('easycheck/auth'); $data['text_heading'] = $this->language->get('text_heading'); $data['text_describe'] = $this->language->get('text_describe'); $data['text_savetime'] = $this->language->get('text_savetime'); $data['text_reg_log'] = $this->language->get('text_reg_log'); $data['text_proceedguest'] = $this->language->get('text_proceedguest'); $data['text_guest'] = $this->language->get('text_guest'); $data['text_or'] = $this->language->get('text_or'); $data['btn_continue'] = $this->language->get('btn_continue'); $data['btn_facebook'] = $this->language->get('btn_facebook'); $data['btn_gplus'] = $this->language->get('btn_gplus'); $data['input_email'] = $this->language->get('input_email'); $data['input_passd'] = $this->language->get('input_passd'); $data['check_availability'] = $this->url->link('easycheck/auth/check_availability'); $data['login'] = $this->url->link('easycheck/auth/login'); $data['guest_login'] = $this->url->link('easycheck/auth/guest_login'); $data['address_url'] = $this->url->link('easycheck/address'); $data['cant_access'] = $this->language->get('cant_access'); $data['forgot_password'] = $this->url->link('account/forgotten', '', 'SSL'); ///////////////////////facebook & google login start//////////////////////////////// $appId = $this->settings['step']['facebook_login']['app_id']; $secret = $this->settings['step']['facebook_login']['app_secret']; $data['appId'] = $appId; $data['secret'] = $secret; //google login settings $this->load->library('googleSetup'); $client = new apiClient(); $redirect_url = HTTP_SERVER . 'index.php?route=easycheck/checkout'; $client->setClientId('702107489335-fsutq69eq4turib43ksldj8t59dsckul.apps.googleusercontent.com'); $client->setClientSecret('vvNUGsKFe3_pA8aK4w-LysBS'); $client->setDeveloperKey('702107489335-fsutq69eq4turib43ksldj8t59dsckul.apps.googleusercontent.com'); $client->setRedirectUri($redirect_url); $client->setApprovalPrompt(false); $oauth2 = new apiOauth2Service($client); $data['client'] = $client; $url = $client->createAuthUrl(); $data['url'] = $url; if (isset($this->request->get['code'])) { $client->authenticate(); $info = $oauth2->userinfo->get(); if (isset($info['given_name']) && $info['given_name'] != "") { $name = $info['given_name']; } else { $name = $info['name']; } $user_table = array('firstname' => $name, 'lastname' => $info['family_name'], 'email' => $info['email'], 'telephone' => '', 'fax' => '', 'password' => substr(md5(uniqid(rand(), true)), 0, 9), 'company' => '', 'company_id' => '', 'tax_id' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'postcode' => '', 'country_id' => '', 'zone_id' => '', 'customer_group_id' => 1, 'status' => 1, 'approved' => 1); $this->load->model('account/customer'); //getting customer info if already exists $users_check = $this->model_account_customer->getCustomerByEmail($info['email']); //adding customer if new if (empty($users_check)) { $this->model_account_customer->addFacebookGoogleCustomer($user_table); } $users_check = $this->model_account_customer->getCustomerByEmail($info['email']); //loging in the customer $users_pass = $this->customer->login($info['email'], '', true); $this->session->data['customer_id'] = $users_check['customer_id']; if ($users_pass == true) { echo '<script>window.opener.location.href ="' . $redirect_url . '"; window.close();</script>'; } else { echo '<script>window.opener.location.href ="' . $redirect_url . '"; window.close();</script>'; } } ///////////////////////facebook & google login start//////////////////////////////// unset($this->session->data['guest']); unset($this->session->data['payment_address']); unset($this->session->data['shipping_address']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/easycheck/auth.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/easycheck/auth.tpl', $data); } }