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;
 }
Ejemplo n.º 2
0
 public function testSettersGetters()
 {
     $client = new apiClient();
     $client->setClientId("client1");
     $client->setClientSecret('client1secret');
     $client->setState('1');
     $client->setApprovalPrompt('force');
     $client->setAccessType('offline');
     global $apiConfig;
     $this->assertEquals('client1', $apiConfig['oauth2_client_id']);
     $this->assertEquals('client1secret', $apiConfig['oauth2_client_secret']);
     $client->setRedirectUri('localhost');
     $client->setApplicationName('me');
     $client->setUseObjects(false);
     $this->assertEquals('object', gettype($client->getAuth()));
     $this->assertEquals('object', gettype($client->getCache()));
     $this->assertEquals('object', gettype($client->getIo()));
     $client->setAuthClass('apiAuthNone');
     $client->setAuthClass('apiOAuth2');
     try {
         $client->setAccessToken(null);
         die('Should have thrown an apiAuthException.');
     } catch (apiAuthException $e) {
         $this->assertEquals('Could not json decode the access token', $e->getMessage());
     }
     $token = json_encode(array('access_token' => 'token'));
     $client->setAccessToken($token);
     $this->assertEquals($token, $client->getAccessToken());
 }
Ejemplo n.º 3
0
/**
 * Load the list of upcoming events in the UPL and return an array containing
 * an array of each event's information.
 */
function loadEvents()
{
    if (!class_exists('apiClient')) {
        return array();
    }
    // Load up the Google API client
    $client = new apiClient();
    $client->setApplicationName('UPL Website');
    $client->setUseObjects(true);
    apiKey($client);
    $cal = new apiCalendarService($client);
    // List all events in the UPL calendar
    $calendarId = '*****@*****.**';
    $args = array('singleEvents' => true, 'orderBy' => 'startTime', 'maxResults' => 5, 'timeMin' => date(DateTime::RFC3339));
    $events = $cal->events->listEvents($calendarId, $args);
    // Make sure that we at least have some events
    if (!$events) {
        return array();
    }
    $events = $events->getItems();
    if (!is_array($events)) {
        return array();
    }
    // Just a little helper to convert dates
    function makeDate($evtDate)
    {
        return DateTime::createFromFormat(DateTime::RFC3339, $evtDate->getDateTime());
    }
    function mapEvent($event)
    {
        return array('summary' => $event->getSummary(), 'start' => makeDate($event->getStart()), 'end' => makeDate($event->getEnd()), 'description' => $event->getDescription(), 'link' => $event->getHtmlLink());
    }
    // Retrieve all our events
    return array_map(mapEvent, $events);
}
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 /**
  * Constructor and Login
  * @param $buy
  * @return Oara_Network_Publisher_Buy_Api
  */
 public function __construct($credentials)
 {
     $client = new apiClient();
     $client->setApplicationName("AffJet");
     $client->setClientId($credentials['clientId']);
     $client->setClientSecret($credentials['clientSecret']);
     $client->setAccessToken($credentials['oauth2']);
     $client->setAccessType('offline');
     $this->_client = $client;
     $this->_gan = new apiGanService($client);
 }
 private function getGoogleClient($config)
 {
     require_once LIBS_DIR . '/google-api-php-client/src/apiClient.php';
     require_once LIBS_DIR . '/google-api-php-client/src/contrib/apiOauth2Service.php';
     $client = new apiClient();
     $client->setApplicationName($config['application_name']);
     $client->setClientId($config['client_id']);
     $client->setClientSecret($config['client_secret']);
     $client->setRedirectUri($config['redirect_url']);
     $client->setScopes(array('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'));
     return $client;
 }
Ejemplo n.º 7
0
 /**
  * connect
  */
 protected function connect()
 {
     $client = new apiClient();
     $client->setApplicationName("Google Application");
     //*********** Replace with Your API Credentials **************
     $client->setClientId($this->clientId);
     $client->setClientSecret($this->clientSecret);
     $client->setRedirectUri($this->redirectUri);
     //        $client->setDeveloperKey('AIzaSyBiUF9NmJKGwbJCDOQIoF2NxMgtYjwI1c8');
     //************************************************************
     $client->setScopes(array('https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'));
     return $client;
 }
Ejemplo n.º 8
0
 /**
  * @return apiClient
  */
 private function createClient()
 {
     require_once 'apiClient.php';
     $client = new apiClient();
     /*$client->setClientId($this->getClientID());
       $client->setClientSecret($this->getClientSecret());
       $client->setRedirectUri($this->getRedirectUri());
       $client->setDeveloperKey($this->getDeveloperKey());
       $client->setApplicationName(yii::app()->name);*/
     $client->setClientId(Yii::app()->functions->getOptionAdmin("google_client_id"));
     $client->setClientSecret(Yii::app()->functions->getOptionAdmin("google_client_secret"));
     $client->setRedirectUri(Yii::app()->functions->getOptionAdmin("google_client_redirect_ulr"));
     $client->setDeveloperKey($this->getDeveloperKey());
     $client->setApplicationName(yii::app()->name);
     return $client;
 }
Ejemplo n.º 9
0
 public function index()
 {
     $this->id = "content";
     $this->template = "login/login.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $session = Registry::get('session');
     $this->load->model('user/auth');
     $this->load->model('user/user');
     $this->load->model('user/prefs');
     $this->load->model('user/google');
     $this->load->model('domain/domain');
     $this->load->model('folder/folder');
     $this->document->title = $this->data['text_login'];
     $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);
     $oauth2 = new apiOauth2Service($client);
     if (isset($_GET['code'])) {
         $client->authenticate();
         $session->set("access_token", $client->getAccessToken());
         header('Location: ' . GOOGLE_REDIRECT_URL);
     }
     if ($session->get("access_token")) {
         $client->setAccessToken($session->get("access_token"));
     }
     if ($client->getAccessToken()) {
         $session->set("access_token", $client->getAccessToken());
         $token = json_decode($session->get("access_token"));
         if (isset($token->{'access_token'}) && isset($token->{'refresh_token'})) {
             $account = $oauth2->userinfo->get();
             $this->model_user_google->check_for_account($account);
             $this->model_user_google->update_tokens($account['email'], $account['id'], $token);
             header("Location: " . SITE_URL . "search.php");
             exit;
         }
     }
     $this->render();
 }
Ejemplo n.º 10
0
 private function init()
 {
     $client = new \apiClient();
     $client->setApplicationName("Share1Book Test Page");
     $client->setDeveloperKey($this->apiKey);
     $service = new \apiBooksService($client);
     $volumes = $service->volumes;
     $optParams['maxResults'] = 1;
     $optParams['country'] = 'FR';
     $optParams['fields'] = 'kind,totalItems,items(volumeInfo(title,authors,imageLinks,description,publisher,publishedDate,industryIdentifiers))';
     $q = $this->isbn10 ? $this->isbn10 : ($this->isbn13 ? $this->isbn13 : ($this->asin ? $this->asin : ""));
     \Sb\Trace\Trace::addItem("requetage de google avec {$q}");
     $this->results = $volumes->listVolumes($q, $optParams);
     if ($this->results && count($this->results) > 0) {
         if (array_key_exists('items', $this->results)) {
             if (count($this->results['items']) > 0) {
                 $bookInfo = $this->results['items'][0];
                 $this->volumeInfo = $bookInfo['volumeInfo'];
             }
         }
     }
 }
Ejemplo n.º 11
0
 public function refresh_access_token($email = '')
 {
     if ($email == '') {
         return '';
     }
     $query = $this->db->query("SELECT refresh_token FROM " . TABLE_GOOGLE . " WHERE email=?", array($email));
     if (!isset($query->row['refresh_token'])) {
         return '';
     }
     $client = new apiClient();
     $client->setApplicationName(GOOGLE_APPLICATION_NAME);
     $client->setClientId(GOOGLE_CLIENT_ID);
     $client->setClientSecret(GOOGLE_CLIENT_SECRET);
     $client->setRedirectUri(GOOGLE_REDIRECT_URL);
     $client->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
     $client->refreshToken($query->row['refresh_token']);
     $s = $client->getAccessToken();
     $a = json_decode($s);
     if (isset($a->{'access_token'})) {
         return $a->{'access_token'};
     }
     return '';
 }
Ejemplo n.º 12
0
<?php

/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiBooksService.php';
$client = new apiClient();
$client->setApplicationName("My_Books_API_Example");
$service = new apiBooksService($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
foreach ($results['items'] as $item) {
    print $item['volumeInfo']['title'] . '<br>';
}
Ejemplo n.º 13
0
<?php

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiWebfontsService.php';
$client = new apiClient();
$client->setApplicationName("Google WebFonts PHP Starter Application");
// Visit https://code.google.com/apis/console?api=webfonts
// to generate your developer key.
// $client->setDeveloperKey('insert_your_developer_key');
$service = new apiWebfontsService($client);
$fonts = $service->webfonts->listWebfonts();
print "<h1>Fonts</h1><pre>" . print_r($fonts, true) . "</pre>";
Ejemplo n.º 14
0
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiPagespeedonlineService.php';
$client = new apiClient();
$client->setApplicationName("PageSpeedOnline_Example_App");
$service = new apiPagespeedonlineService($client);
if (isset($_GET['url'])) {
    $result = $service->pagespeedapi->runpagespeed($_GET['url']);
}
?>
<!doctype html>
<html>
<head><link rel='stylesheet' href='style.css' /></head>
<body>
<header><h1>Google Page Speed Sample App</h1></header>
<div class="box">
  <div id="search">
    <form id="url" method="GET" action="index.php">
      <input name="url" class="url" type="text">
      <input type="submit" value="Analyze Performance">
<?php

require_once 'login/src/apiClient.php';
require_once 'login/src/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName("flowerforevervn");
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email'));
//echo $authUrl = $client->createAuthUrl();
$oauth2 = new apiOauth2Service($client);
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
if (isset($_REQUEST['logout'])) {
    unset($_SESSION['token']);
    unset($_SESSION['google_data']);
    //Google session data unset
    $client->revokeToken();
}
if ($client->getAccessToken()) {
    $user = $oauth2->userinfo->get();
    //$_SESSION['google_data']=$user; // Storing Google User Data in Session
    header("location: home.php");
    $_SESSION['token'] = $client->getAccessToken();
} else {
    $authUrl = $client->createAuthUrl();
Ejemplo n.º 16
0
<?php

require_once 'config.php';
require_once 'src/apiClient.php';
require_once 'src/contrib/apiPlusService.php';
require_once 'src/gMaps.php';
$mysqli = new mysqli(SERVER, USER, PASSWORD, DATABASE);
$gmap = new gMaps(MAP_KEY);
$client = new apiClient();
$plus = new apiPlusService($client);
session_start();
$client->setApplicationName('Globe +');
$client->setClientId(PLUS_CLIENT_ID);
$client->setClientSecret(PLUS_CLIENT_SECRET);
$client->setRedirectUri(PLUS_REDIRECT_URI);
$client->setDeveloperKey(PLUS_DEVELOPPER_KEY);
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['access_token'] = $client->getAccessToken();
    header('Location: ' . URL . $_SERVER['PHP_SELF']);
}
if (isset($_GET['error'])) {
    header('Location: ' . URL . '?status=error');
    die;
}
if (isset($_SESSION['access_token'])) {
    $client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
    $me = $plus->people->get('me');
    // These fields are currently filtered through the PHP sanitize filters.
Ejemplo n.º 17
0
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

require_once '../server.php';
require_once '../../key.php';
require_once 'src/apiClient.php';
session_start();

$client = new apiClient();
$client -> setApplicationName('Google Contacts');
$client -> setScopes("http://www.google.com/m8/feeds/");
$client -> setClientId(GOOGLE_CLIENT_ID);
$client -> setClientSecret(GOOGLE_CLIENT_SECRET);
$client -> setRedirectUri(AUTH_BASE_URL . '/gmail/index.php');

//$client->setDeveloperKey('insert_your_developer_key');

if (isset($_GET['code']))
{
	$client -> authenticate();
	$_SESSION['token'] = $client -> getAccessToken();
}

$match = false;
Ejemplo n.º 18
0
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
if (ini_get('register_globals') === "1") {
    die("register_globals must be turned off before using the starter application");
}
require_once 'google-api-php-client/src/apiClient.php';
require_once 'google-api-php-client/src/contrib/apiPlusService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google+ PHP Starter Application");
$client->setClientId('583952610464-skm0ipo4hms1qleut4jinp106fnf0daf.apps.googleusercontent.com');
$client->setClientSecret('FijubFKkMgXvH-UQV4SfEypV');
$client->setRedirectUri('http://localhost/googleplus/index.php');
$client->setDeveloperKey('AIzaSyDidZKyQlgizNL3lgPRHDyucL5sOxqGqXg');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me', 'https://picasaweb.google.com/data/'));
$plus = new apiPlusService($client);
if (isset($_REQUEST['logout'])) {
    $files = glob('images/*');
    // get all file names
    foreach ($files as $file) {
        // iterate files
        if (is_file($file)) {
            unlink($file);
        }
        // delete file
<?php

require_once 'login/src/apiClient.php';
require_once 'login/src/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName("");
$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email'));
//echo $authUrl = $client->createAuthUrl();
$oauth2 = new apiOauth2Service($client);
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
if (isset($_REQUEST['logout'])) {
    unset($_SESSION['token']);
    unset($_SESSION['google_data']);
    //Google session data unset
    $client->revokeToken();
}
if ($client->getAccessToken()) {
    $user = $oauth2->userinfo->get();
    //$_SESSION['google_data']=$user; // Storing Google User Data in Session
    header("location: home.php");
    $_SESSION['token'] = $client->getAccessToken();
} else {
    $authUrl = $client->createAuthUrl();
Ejemplo n.º 20
0
<?php

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiTranslateService.php';
$client = new apiClient();
$client->setApplicationName('Google Translate PHP Starter Application');
// Visit https://code.google.com/apis/console?api=translate to generate your
// client id, client secret, and to register your redirect uri.
// $client->setDeveloperKey('insert_your_developer_key');
$service = new apiTranslateService($client);
$langs = $service->languages->listLanguages();
print "<h1>Languages</h1><pre>" . print_r($langs, true) . "</pre>";
$translations = $service->translations->listTranslations('Hello', 'hi');
print "<h1>Translations</h1><pre>" . print_r($translations, true) . "</pre>";
Ejemplo n.º 21
0
<?php

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiCalendarService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Calendar PHP Starter Application");
// Visit https://code.google.com/apis/console?api=calendar to generate your
// client id, client secret, and to register your redirect uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
$cal = new apiCalendarService($client);
if (isset($_GET['logout'])) {
    unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
    $client->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()) {
    $calList = $cal->calendarList->listCalendarList();
    print "<h1>Calendar List</h1><pre>" . print_r($calList, true) . "</pre>";
    $_SESSION['token'] = $client->getAccessToken();
} else {
    $authUrl = $client->createAuthUrl();
Ejemplo n.º 22
0
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once 'apiClient.php';
require_once 'apiPredictionService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Prediction API PHP Starter Application");
// Visit https://code.google.com/apis/console/?api=prediction to generate
// your oauth2_client_id, oauth2_client_secret, and to register your
// oauth2_redirect_uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
$client->setScopes(array('https://www.googleapis.com/auth/prediction'));
$predictionService = new apiPredictionService($client);
$trainedmodels = $predictionService->trainedmodels;
if (isset($_REQUEST['logout'])) {
    unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
    $client->authenticate();
Ejemplo n.º 23
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
include "config.php";
$user_ip = $_SERVER["REMOTE_ADDR"];
if (!$user_ip || $user_ip == "") {
    $user_ip = $_SERVER["SERVER_ADDR"];
}
require_once $gapi_client_path . "apiClient.php";
require_once $gapi_client_path . "contrib/apiPlusService.php";
session_start();
$client = new apiClient();
$client->setApplicationName("ProfileRoom+");
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($base_url . "index.php");
$client->setDeveloperKey($developer_key);
$client->setScopes(array("https://www.googleapis.com/auth/plus.me"));
$plus = new apiPlusService($client);
if (isset($_GET["code"])) {
    $client->authenticate();
    $_SESSION["access_token"] = $client->getAccessToken();
    header("Location: " . $base_url . "check.php");
}
if (isset($_GET["error"])) {
    unset($_SESSION["access_token"]);
    header("Location: " . $base_url);
}
Ejemplo n.º 24
0
<?php

include 'constants.php';
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once 'apiClient.php';
require_once 'apiCalendarService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("NUS Timetable Sync");
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->setRedirectUri('http://localhost/ivle/test.php');
$client->setDeveloperKey($developerKey);
$apiClient = new apiClient();
$cal = new apiCalendarService($client);
if (isset($_SESSION['logout'])) {
    unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
    $client->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()) {
    $start_date_reference = array("Monday" => 13, "Tuesday" => 14, "Wednesday" => 15, "Thursday" => 16, "Friday" => 17, "Saturday" => 18, "Sunday" => 19);
    foreach ($_SESSION['modules'] as $module) {
        $event = new Event();
Ejemplo n.º 25
0
if (empty($_COOKIE['hexauser'])) {
    echo json_encode(array('status' => 'error', 'message' => 'empty session'));
    exit;
}
$cookie = explode('+', $_COOKIE['hexauser']);
if (empty($cookie) || count($cookie) < 2) {
    setcookie('hexauser', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER['HTTP_HOST']);
    echo json_encode(array('status' => 'error', 'message' => 'incomplete session'));
    exit;
}
$userId = $cookie[0];
$sessionId = $cookie[1];
require_once '../libs/google/apiClient.php';
//require_once '../libs/google/contrib/apiOauth2Service.php';
$client = new apiClient();
$client->setApplicationName('Hexagame');
$client->setClientId($config['googleId']);
$client->setClientSecret($config['googleSecret']);
$client->setRedirectUri($config['googleRedirect']);
$client->setApprovalPrompt('auto');
//$oauth2 = new apiOauth2Service($client);
$db = new PDO($config['db'], $config['dbUser'], $config['dbPassword']);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$stmt = $db->prepare("SELECT `name`, `email`, `token` FROM `users`, `sessions` WHERE `sessions`.`user_id` = `users`.`id` AND `sessions`.`id` = :sessionId AND `users`.`id` = :userId LIMIT 1");
$stmt->execute(array(':userId' => $userId, ':sessionId' => $sessionId));
$user = $stmt->fetch();
if (!$user) {
    setcookie('hexauser', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER['HTTP_HOST']);
    echo json_encode(array('status' => 'error', 'message' => 'wrong session'));
    exit;
}
Ejemplo n.º 26
0
<?php

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiAnalyticsService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Analytics PHP Starter Application");
// Visit https://code.google.com/apis/console?api=analytics to generate your
// client id, client secret, and to register your redirect uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
$service = new apiAnalyticsService($client);
if (isset($_GET['logout'])) {
    unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()) {
    $props = $service->management_webproperties->listManagementWebproperties("~all");
    print "<h1>Web Properties</h1><pre>" . print_r($props, true) . "</pre>";
    $accounts = $service->management_accounts->listManagementAccounts();
    print "<h1>Accounts</h1><pre>" . print_r($accounts, true) . "</pre>";
Ejemplo n.º 27
0
 public static function getClient()
 {
     $client = new apiClient();
     $client->setApplicationName('GAnalytics joomla extension');
     $client->setClientId(GAnalyticsHelper::getComponentParameter('client-id'));
     $client->setClientSecret(GAnalyticsHelper::getComponentParameter('client-secret'));
     $uri = JFactory::getURI();
     if (filter_var($uri->getHost(), FILTER_VALIDATE_IP)) {
         $uri->setHost('localhost');
     }
     $client->setRedirectUri($uri->toString(array('scheme', 'host', 'port', 'path')) . '?option=com_ganalytics&view=import');
     $client->setUseObjects(true);
     $service = new apiAnalyticsService($client);
     return $client;
 }
Ejemplo n.º 28
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiLatitudeService.php';
$client = new apiClient();
// Visit https://code.google.com/apis/console to generate your
// oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
// $client->setClientId('insert_your_oauth2_client_id');
// $client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setApplicationName("Latitude_Example_App");
$service = new apiLatitudeService($client);
if (isset($_REQUEST['logout'])) {
    unset($_SESSION['access_token']);
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['access_token'] = $client->getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
    $client->setAccessToken($_SESSION['access_token']);
} else {
    $authUrl = $client->createAuthUrl();
}
Ejemplo n.º 29
0
<?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);
}
Ejemplo n.º 30
0
<?php

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiShoppingService.php';
$client = new apiClient();
$client->setApplicationName("Google Shopping PHP Starter Application");
// Visit https://code.google.com/apis/console?api=shopping to generate your
// Simple API Key.
//$client->setDeveloperKey('insert_your_api_key');
$service = new apiShoppingService($client);
// Valid source values are "public", "cx:cse", and "gan:pid"
// See http://code.google.com/apis/shopping/search/v1/getting_started.html#products-feed
$source = "public";
// For more information about full text search with the shopping API, please
// see http://code.google.com/apis/shopping/search/v1/getting_started.html#text-search
$query = "\"mp3 player\" | ipod";
//The order in which the API returns products is defined by a ranking criterion.
// See http://code.google.com/apis/shopping/search/v1/getting_started.html#ranking
$ranking = "relevancy";
$results = $service->products->listProducts($source, array("country" => "US", "q" => $query, "rankBy" => $ranking));
print "<h1>Shopping Results</h1><pre>" . print_r($results, true) . "</pre>";