public function __construct() { parent::__construct($consumerKey, $consumerSecret); $this->LOG = Config::getLogObject(); if (func_num_args()) { $userID = func_get_arg(0); $this->userSettings = new goUserSettings($userID); $this->setToken($this->userSettings->getFoursquareOAuthToken(), $this->userSettings->getFoursquareOAuthTokenSecret()); echo $this->userSettings->getFoursquareOAuthToken() . " " . $this->userSettings->getFoursquareOAuthTokenSecret(); } //if }
<?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; }
/** * Connect to Foursquare * @return bool|\Foursquare */ function connect($username = false) { if (!empty(\Idno\Core\site()->config()->foursquare)) { $foursquare = new \EpiFoursquare(\Idno\Core\site()->config()->foursquare['clientId'], \Idno\Core\site()->config()->foursquare['secret']); if ($this->hasFoursquare()) { if ($user = \Idno\Core\site()->session()->currentUser()) { try { if (!empty($username)) { $foursquare->setAccessToken($user->foursquare[$username]['access_token']); } else { if (!empty($user->foursquare['access_token'])) { $foursquare->setAccessToken($user->foursquare['access_token']); } } } catch (\Exception $e) { \Idno\Core\site()->session()->addMessage("Unfortunately we couldn't connect to Foursquare."); } } } return $foursquare; } return false; }
<?php ob_start(); require_once 'EpiCurl.php'; require_once 'EpiFoursquare.php'; $clientId = 'USAVZNQTYR1CKIJDJXM0BFYV3EYOC5GMECOOAPWSSWG3BOHS'; $clientSecret = 'RKSAEP0QMFMBO4XSXFWIJECDCWY3VGY4K54KIP2L21UP5WW2'; //$code = 'BFVH1JK5404ZUCI4GUTHGPWO3BUIUTEG3V3TKQ0IHVRVGVHS'; //$accessToken = 'DT32251AY1ED34V5ADCTNURTGSNHWXCNTOMTQM5ANJLBLO2O'; $redirectUri = 'http://server.neatocode.com/spaceneedle/simpleTest.php'; //$userId = '5763863'; $fsObj = new EpiFoursquare($clientId, $clientSecret, $accessToken); $fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret); $example_images = array('http://server.neatocode.com/spaceneedle/example_desert.png', 'http://server.neatocode.com/spaceneedle/example_drinks.png', 'http://server.neatocode.com/spaceneedle/example_food.png'); $ll = "36.060944,-115.133735"; // Default to the Venetian. if (htmlspecialchars($_GET["ll"])) { $ll = htmlspecialchars($_GET["ll"]); } $item = 0; // Default to item 0. if (htmlspecialchars($_GET["item"])) { $item = htmlspecialchars($_GET["item"]); } $venue = $fsObjUnAuth->get('/venues/explore', array('ll' => $ll, 'venuePhotos' => 1)); $items = $venue->response->groups[0]->items; $default_reason = $venue->response->groups[0]->items[0]->reasons->items[0]->message; $first_item = true; $count = 0; $item = $items[$item]; //foreach ($items as &$item) {
<?php //Put in the key and secret for your Foursquare app //Your values will be different than mine $consumer_key = 'AROV4OCBZMPAMSHLCF3LLYWQQ0W0F2WH1K1BDZDGBW1OFJSM'; $consumer_secret = 'IT5NN1BSTKCORZ3YVC32BRAJD5O4201TCCAGAK2KAMUYHOQD'; //$consumer_key = "XB1NE31CJ4U22EF2GA53C4ULR3SL2BG21G1M5VTRCZ3K1XW5"; //$consumer_secret = "3RHRD1KJLGFFHKDMD4SCE11NHNDCFUPOIPOQW4VGKLADFKC1"; $loginurl = ""; //Includes the foursquare-asyc library files require_once 'EpiCurl.php'; require_once 'EpiOAuth.php'; require_once 'EpiFoursquare.php'; //session_start(); try { $foursquareObj = new EpiFoursquare($consumer_key, $consumer_secret); $results = $foursquareObj->getAuthorizeUrl(); $loginurl = $results['url'] . "?oauth_token=" . $results['oauth_token']; echo $loginurl; $_SESSION['secret'] = $results['oauth_token_secret']; } catch (Execption $e) { echo $e; //If there is a problem throw an exception } echo "<a href='" . $loginurl . "'>Login Via Foursquare</a>"; //Display the Foursquare login link echo "<br>"; //This is your OAuth token and secret generated above //The OAuth token is part of the Foursquare link above //They are dynamic and will change each time you refresh the page //If everything is working correctly both of these will show up when you open index.php
<?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;
function explore_venues($data) { $foursquare_obj = new EpiFoursquare($this->client_id, $this->client_secret); return $foursquare_obj->get('/venues/explore', $data); }
<?php ob_start(); require_once 'EpiCurl.php'; require_once 'EpiFoursquare.php'; $clientId = 'a40b1aece83e8d94a08fff1e94f87c2f04af2881a'; $clientSecret = 'e83c621567e6c430848db6dc5dde94b9'; $code = 'BFVH1JK5404ZUCI4GUTHGPWO3BUIUTEG3V3TKQ0IHVRVGVHS'; $accessToken = 'DT32251AY1ED34V5ADCTNURTGSNHWXCNTOMTQM5ANJLBLO2O'; $redirectUri = 'http://www.jaisenmathai.com/foursquare-async/simpleTest.php'; $userId = '5763863'; $fsObj = new EpiFoursquare($clientId, $clientSecret, $accessToken); $fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret); ?> <h1>Simple test to make sure everything works ok</h1> <h2><a href="javascript:void(0);" onclick="viewSource();">View the source of this file</a></h2> <div id="source" style="display:none; padding:5px; border: dotted 1px #bbb; background-color:#ddd;"> <?php highlight_file(__FILE__); ?> </div> <hr> <?php if (!isset($_GET['code']) && !isset($_COOKIE['access_token'])) { ?> <h2>Generate the authorization link</h2>
/** * 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"); }
/** * * * @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; }
/** * 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'); }
<?php ob_start(); require_once 'EpiCurl.php'; require_once 'EpiFoursquare.php'; $clientId = 'USAVZNQTYR1CKIJDJXM0BFYV3EYOC5GMECOOAPWSSWG3BOHS'; $clientSecret = 'RKSAEP0QMFMBO4XSXFWIJECDCWY3VGY4K54KIP2L21UP5WW2'; $code = 'HFQ5BADYIVKDWLHB0LK2OKS2BQR1TJIUSCYQJZFUJ2UQPGAM'; $accessToken = 'HFQ5BADYIVKDWLHB0LK2OKS2BQR1TJIUSCYQJZFUJ2UQPGAM'; $redirectUri = 'http://server.neatocode.com/spaceneedle/simpleTest.php'; //$userId = '5763863'; $fsObj = new EpiFoursquare($clientId, $clientSecret, $accessToken); $fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret); ?> <script type="text/javascript"> function viewSource() { document.getElementById("source").style.display = "block"; } </script> <h1>Simple test to make sure everything works ok</h1> <h2><a href="javascript:void(0);" onclick="viewSource();">View the source of this file</a></h2> <div id="source" style="display:none; padding:5px; border: dotted 1px #bbb; background-color:#ddd;"> <?php highlight_file(__FILE__); ?> </div> <hr>
<div class="info-alert"> <h2>' . T_('Foursquare is not configured correctly.') . '</h2> <p>' . T_('The "Where Is Everyone" feature cannot work without Foursquare. Please configure Foursquare or turn off "Where Is Everyone".') . '</p> </div>'; } // we continue on, because we still might be able to show user data (if they have an access token) // this would happen if foursquare was setup, users granted access, then foursquare was removed. } $historyData = array(); $i = 0; foreach ($users as $k => $data) { // Skip users who don't have foursquare setup if (empty($data['access_token'])) { continue; } $fsObj = new EpiFoursquare($config['fs_client_id'], $config['fs_client_secret'], $data['access_token']); try { $creds = $fsObj->get('/users/' . $data['user_id'] . '/checkins'); } catch (EpiFoursquareException $e) { echo 'We caught an EpiOAuthException'; echo $e->getMessage(); break; } catch (Exception $e) { echo 'We caught an unexpected Exception'; echo $e->getMessage(); break; } $photo = getAvatarPath($data['avatar'], $data['gravatar']); foreach ($creds->response->checkins->items as $checkin) { // Skip shouts, etc if ($checkin->type != 'checkin') {
/** * getFoursquareWhatsNewData * * Adds foursquare data to the whats new data array. * * @param array $whatsNewData * * @return mixed - array on success or false on failure */ function getFoursquareWhatsNewData($whatsNewData) { $fcmsError = FCMS_Error::getInstance(); $fcmsDatabase = Database::getInstance($fcmsError); $fcmsUser = User::getInstance($fcmsError, $fcmsDatabase); include_once 'socialmedia.php'; include_once 'thirdparty/foursquare/EpiFoursquare.php'; include_once 'thirdparty/foursquare/EpiCurl.php'; $users = getFoursquareUsersData(); $config = getFoursquareConfigData(); // TODO // Move this check inside the getFoursquareConfigData and have it return false on failure. // Foursquare hasn't been setup or is invalid if (empty($config['fs_client_id']) or empty($config['fs_client_secret'])) { // If admin is viewing, alert them that the config is missing/messed up if ($fcmsUser->access < 2) { echo ' <div class="info-alert"> <h2>' . T_('Foursquare is not configured correctly.') . '</h2> <p>' . T_('The "Where Is Everyone" feature cannot work without Foursquare. Please configure Foursquare or turn off "Where Is Everyone".') . '</p> <p><a href="admin/foursquare.php">' . T_('Configure Foursquare') . '</a></p> <p><a href="admin/config.php?view=plugins">' . T_('Turn Off "Where is Everyone"') . '</a></p> </div>'; } return $whatsNewData; } $foursquareData = array(); if (count($users[0]) > 0) { $timeago = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y')); $i = 0; foreach ($users as $k => $data) { // Skip users who don't have foursquare setup if (empty($data['access_token'])) { continue; } $fsObj = new EpiFoursquare($config['fs_client_id'], $config['fs_client_secret'], $data['access_token']); try { $params = array('afterTimestamp' => $timeago); $creds = $fsObj->get('/users/' . $data['user_id'] . '/checkins', $params); } catch (EpiFoursquareException $e) { echo 'We caught an EpiOAuthException'; echo $e->getMessage(); return false; } catch (Exception $e) { echo 'We caught an unexpected Exception'; echo $e->getMessage(); return false; } foreach ($creds->response->checkins->items as $checkin) { // Skip shouts, etc if ($checkin->type != 'checkin') { continue; } $date = date('Y-m-d H:i:s', $checkin->createdAt); $sort = $checkin->createdAt; $shout = isset($checkin->shout) ? $checkin->shout : ''; // Save data $whatsNewData[] = array('id' => '', 'date' => $date, 'title' => $checkin->venue->name, 'userid' => $data['fcms_user_id'], 'id2' => $shout, 'id3' => '', 'type' => 'WHEREISEVERYONE'); } } } // Order is messed up now, so fix it $whatsNewData = subval_sort($whatsNewData, 'date'); $whatsNewData = array_reverse($whatsNewData); return $whatsNewData; }