Esempio n. 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;
}
Esempio n. 2
0
    ?>
<a href="<?php 
    echo $authorizeUrl;
    ?>
"><?php 
    echo $authorizeUrl;
    ?>
</a>

<?php 
} else {
    ?>
<h2>Display your own badges</h2>
<?php 
    if (!isset($_COOKIE['access_token'])) {
        $token = $fsObjUnAuth->getAccessToken($_GET['code'], $redirectUri);
        setcookie('access_token', $token->access_token);
        $_COOKIE['access_token'] = $token->access_token;
    }
    $fsObjUnAuth->setAccessToken($_COOKIE['access_token']);
    $badges = $fsObjUnAuth->get('/users/self/badges');
    ?>
<pre><?php 
    var_dump($badges->response);
    ?>
</pre>
<?php 
}
?>

<hr>
 /**
  *
  *
  * @return array
  */
 function foursquare()
 {
     App::import("Vendor", "Users.foursquare/EpiCurl");
     App::import("Vendor", "Users.foursquare/EpiFoursquare");
     $response = array();
     $foursquareObj = new EpiFoursquare(FOURSQUARE_CLIENT_ID, FOURSQUARE_CLIENT_SECRET);
     $redirectUri = Router::url(array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'foursquare'), true);
     if (!isset($_GET['code']) && !isset($_SESSION['fs_access_token'])) {
         $url = $foursquareObj->getAuthorizeUrl($redirectUri);
         $response['url'] = $url;
     } else {
         if (!isset($_SESSION['fs_access_token'])) {
             $token = $foursquareObj->getAccessToken($_GET['code'], $redirectUri);
             //setcookie('fs_access_token', $token->access_token);
             $_SESSION['fs_access_token'] = $token->access_token;
         }
         $foursquareObj->setAccessToken($_SESSION['fs_access_token']);
         $foursquareInfo = $foursquareObj->get('/users/self');
         $user_profile = (array) $foursquareInfo->response;
         $fsToken = $_SESSION['fs_access_token'];
     }
     $response['user_profile'] = isset($user_profile) ? $user_profile : '';
     $response['user_profile']['accessToken'] = isset($fsToken) ? $fsToken : '';
     return $response;
 }
Esempio n. 4
0
 /**
  * displayFoursquareSubmit 
  * 
  * The submit screen for saving foursquare data.
  * 
  * @return void
  */
 function displayFoursquareSubmit()
 {
     $r = getFoursquareConfigData();
     $id = cleanOutput($r['fs_client_id']);
     $secret = cleanOutput($r['fs_client_secret']);
     $url = cleanOutput($r['fs_callback_url']);
     $fsObj = new EpiFoursquare($id, $secret);
     $token = $fsObj->getAccessToken($_GET['code'], $url);
     $fsObjAuth = new EpiFoursquare($id, $secret, $token->access_token);
     $self = $fsObjAuth->get('/users/self');
     $sql = "UPDATE `fcms_user_settings`\n                SET `fs_user_id` = ?,\n                    `fs_access_token` = ?\n                WHERE `user` = ?";
     $params = array($self->response->user->id, $token->access_token, $this->fcmsUser->id);
     if (!$this->fcmsDatabase->update($sql, $params)) {
         $this->displayHeader();
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     header("Location: settings.php?view=foursquare");
 }
Esempio n. 5
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');
 }