Skip to content

Commit

Permalink
removed ad hoc location pull
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesvdvreken committed Aug 2, 2013
1 parent 4fdf4c0 commit 51b628d
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions application/controllers/PlugID/user.php
Expand Up @@ -12,43 +12,18 @@ class User extends API_Controller {

function index() {
$token = $this->is_authenticated();
if (!$token) {
if (!$token)
{
$this->output->set_output('you are not authenticated');
} else {
}
else
{
$this->load->model('access_token_model');
$this->load->model('user_model');
$this->load->driver('service');

$user = $this->access_token_model->get_user($token);

$tokens = $this->user_model->get_tokens($this->auth->user_id, 'foursquare');
$token = reset($tokens);

$this->service->foursquare->set_authentication($token);
$result = json_decode($this->service->foursquare->api('users/self/checkins?limit=1'));
$user_data = json_decode($this->service->foursquare->api('users/self'));

if (isset($result->response->checkins->items) &&
count($result->response->checkins->items) > 0 &&
isset($user_data->response->user))
{
// subdoc
$user_data = $user_data->response->user;

$checkin = $result->response->checkins->items[0];
$location = $checkin->venue->location;

//unset($location->postalCode);
//unset($location->city);
unset($location->country);
unset($location->cc);
//unset($location->address);

$user->location = $location;
$user->first_name = $user_data->firstName;
$user->last_name = $user_data->lastName;
}

$this->output->set_content_type('application/json');
$this->output->set_output(json_encode(compact('user')));
}
Expand Down

0 comments on commit 51b628d

Please sign in to comment.