Exemple #1
0
<?php

$include_path = ini_get('include_path');
ini_set('include_path', '/home/juliomiyares/jittr.com/jittr/gameon/classes' . ':' . $include_path);
require_once 'config.class.php';
require_once 'goutility.class.php';
require_once 'go_usersettings.class.php';
//Includes the foursquare-asyc library files
require_once 'foursquare/EpiCurl.php';
require_once 'foursquare/EpiOAuth.php';
require_once 'foursquare/EpiFoursquare.php';
//Put in the key and secret for your Foursquare app
//Your values will be different than mine
$consumer_key = Config::getFoursquareConsumerKey();
$consumer_secret = Config::getFoursquareConsumerKeySecret();
session_start();
$foursquareObj = new EpiFoursquare($consumer_key, $consumer_secret);
$foursquareObj->setToken($_REQUEST['oauth_token'], $_SESSION['secret']);
$token = $foursquareObj->getAccessToken();
$foursquareObj->setToken($token->oauth_token, $token->oauth_token_secret);
try {
    //Making a call to the API
    $foursquareTest = $foursquareObj->get_user();
    print_r($foursquareTest->response);
} catch (Exception $e) {
    echo "Error: " . $e;
}
Exemple #2
0
 /**
  * Callback for foursquare user authentication
  * 
  * @access public
  * @return void
  */
 public function foursquare_callback()
 {
     $this->mustBeSignedIn();
     // foursquare
     //echo '$_REQUEST[\'oauth_token\'] '. $_REQUEST['oauth_token']."<br>";
     //Put in the key and secret for your Foursquare app
     //Your values will be different than mine
     $foursquare_consumer_key = $this->config->item('foursquare_consumer_key');
     $foursquare_consumer_secret = $this->config->item('foursquare_consumer_secret');
     //session_start();
     //Includes the foursquare-asyc library files
     require_once APPPATH . 'libraries/foursquare/EpiCurl.php';
     require_once APPPATH . 'libraries/foursquare/EpiOAuth.php';
     require_once APPPATH . 'libraries/foursquare/EpiFoursquare.php';
     $foursquareObj = new EpiFoursquare($foursquare_consumer_key, $foursquare_consumer_secret);
     $foursquareObj->setToken($_REQUEST['oauth_token'], $this->userData['foursquare_secret']);
     $token = $foursquareObj->getAccessToken();
     $foursquareObj->setToken($token->oauth_token, $token->oauth_token_secret);
     //echo "<pre>";
     //var_dump($token);
     //if (isset($token->oauth_token) && $foursquareObj->setToken($token->oauth_token, $token->oauth_token_secret)){
     try {
         //Making a call to the API
         $foursquareTest = $foursquareObj->get_user();
         $this->data['foursquare_response'] = $foursquareTest->response;
         print_r($foursquareTest->response);
     } catch (Exception $e) {
         echo "Error: " . $e;
     }
     $this->data['foursquare_token'] = $token->oauth_token;
     $this->userData['foursquare_secret'] = null;
     $this->userData['foursquare_token'] = $token->oauth_token;
     $this->userData['foursquare_token_secret'] = $token->oauth_token_secret;
     $this->User->save($this->userData, array('ignoreModelFields' => true));
     //}
     //$this->load->view('users/accounts', $this->data);
     $this->redirect('/settings/accounts');
 }