Пример #1
0
<?php

require_once 'init.php';
$foursquareObj = new EpiFoursquare($consumer_key, $consumer_secret);
if (!isset($_SESSION['oauth_token'])) {
    $foursquareObj->setToken($_REQUEST['oauth_token'], $_SESSION['secret']);
    $token = $foursquareObj->getAccessToken();
    $_SESSION['oauth_token'] = $token->oauth_token;
    $_SESSION['secret'] = $token->oauth_token_secret;
}
$foursquareObj->setToken($_SESSION['oauth_token'], $_SESSION['secret']);
// User info
$params = array("badges" => 1, "mayor" => 1);
$foursquareUser = $foursquareObj->get_user($params);
$user_info = $foursquareUser->response['user'];
$_SESSION['currentUserID'] = $user_info['id'];
$_SESSION['4sq_user'] = $user_info;
$_SESSION['4sq_obj'] = $foursquareObj;
try {
    // alert if homebase isn't set -> should do this during registration -> after registration, but before page access -> shouldn't be able to get to this page without homebase being set
    // what if homebase isn't a foursquare location?
    /* -> can guide user through creation of venue (cumbersome)
    * -> can set foursquare vid to 0 or -1 and set geolocation (geolong, geolat) via google maps
    */
    //ideally, these items should be stored in the Footprint db to save on 4sq API calls
    //hardcoded homebase
    $homebase = $foursquareObj->get_venue(array("vid" => $homebase_vid));
    // $homebaseVID = 4500522; this should now be instantiated in config.php
    $homebaseGeoLat = $homebase->venue->geolat;
    $homebaseGeoLong = $homebase->venue->geolong;
    $homebaseURL = $homebase->venue->short_url;
Пример #2
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;
}
Пример #3
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');
 }