Example #1
0
 public function obtainToken($callback)
 {
     $helper = new FacebookRedirectLoginHelper($callback);
     if ($this->input->get('code') === null) {
         /**
          * Required permissions
          * public_profile
          * email
          * read_insights		Show analytics data of page in dashboard
          * read_page_mailboxes	Manage page conversations
          * read_mailbox			Manage page mailbox
          * manage_pages			Manage brand pages
          * publish_pages		Take actions on behalf of page
          */
         $loginUrl = $helper->getLoginUrl(array('public_profile', 'user_friends', 'email', 'read_mailbox', 'read_page_mailboxes', 'manage_pages', 'publish_actions', 'publish_pages', 'read_insights'));
         Url::redirect($loginUrl);
         return null;
     } else {
         $session = null;
         try {
             $session = $helper->getSessionFromRedirect();
         } catch (FacebookRequestException $ex) {
             // When Facebook returns an error
         } catch (\Exception $ex) {
             // When validation fails or other local issues
         }
         if ($session) {
             // Logged in
         }
         return $session;
     }
 }
Example #2
0
 public static function once($type, $message, $redirect = null)
 {
     Controller::instance()->input->set_session('alert_once', array('type' => $type, 'message' => htmlspecialchars($message)));
     if ($redirect) {
         Url::redirect($redirect);
     }
 }
Example #3
0
 public function obtainToken($callback)
 {
     $r = null;
     if ($this->input->get('oauth_verifier') === null) {
         $c = $this->_lib->request('POST', $this->_lib->url('oauth/request_token', ''), array('oauth_callback' => $callback, 'x_auth_access_type' => 'write'));
         if ($c == 200) {
             $r = $this->_lib->extract_params($this->_lib->response['response']);
             if ($r['oauth_callback_confirmed'] == true) {
                 $this->input->set_session('request_token', $r);
                 Url::redirect($this->_lib->url('oauth/authenticate', '') . '?oauth_token=' . $r['oauth_token']);
             }
         } else {
             throw new \Exception($this->_lib->response['response'], $c);
         }
     } else {
         if (!($r = $this->input->session('request_token'))) {
             return null;
         }
         $this->input->unset_session('request_token');
         $this->_lib->reconfigure(array('token' => $r['oauth_token'], 'secret' => $r['oauth_token_secret']));
         $c = $this->_lib->request('POST', $this->_lib->url('oauth/access_token', ''), array('oauth_verifier' => $this->input->get('oauth_verifier')));
         if ($c == 200) {
             $r = $this->_lib->extract_params($this->_lib->response['response']);
         }
     }
     return $r;
 }
Example #4
0
 protected function _check_login()
 {
     if (!UserSession::get('user')) {
         if ($this->input->is_ajax_request()) {
             Json::success('Session has been invalidated. Redirecting to login page...', Url::base('auth/login'));
         } else {
             Url::redirect('auth/login');
         }
     }
     return true;
 }
Example #5
0
 public function obtainToken($callback)
 {
     $this->_lib->setApiCallback($callback);
     $r = null;
     if ($this->input->get('code') === null) {
         Url::redirect($this->_lib->getLoginUrl());
     } else {
         $r = json_decode(json_encode($this->_lib->getOAuthToken($this->input->get('code'))), true);
         if (isset($r['code']) && $r['code'] !== 200) {
             throw new InstagramAccessTokenException($r['error_type'] . ' - ' . $r['error_message']);
         }
         return $r;
     }
     return null;
 }
Example #6
0
 public function obtainToken($callback, $scope = array())
 {
     if ($scope) {
         $this->_client->setScopes($scope);
     }
     $this->_client->setRedirectUri($callback);
     $r = null;
     if ($this->input->get('code') === null) {
         Url::redirect($this->_client->createAuthUrl());
     } else {
         $this->_client->authenticate($this->input->get('code'));
         return json_decode($this->_client->getAccessToken(), true);
     }
     return null;
 }
Example #7
0
 public function get($state = null)
 {
     if (!$state) {
         Url::redirect('admin/campaign/pending');
     }
     $filter = array();
     if ($state != 'all') {
         $filter = array('state' => $state);
     }
     $campaigns = $this->_get_campaigns($filter)->sort(array('_id' => 1));
     $r = array();
     foreach ($campaigns as $c) {
         $brand = new Brand($c['brand']);
         $c['brand'] = $brand->filter_one(array('_id' => $c['brand']), array('_id' => true, 'username' => true));
         $r[] = $c;
     }
     $this->_display->view(array('main/app/admin/campaign/index.php'), array('campaigns' => $r));
 }
Example #8
0
 protected function _create()
 {
     Url::redirect('register/' . base64_encode(json_encode(array('type' => 'brand', 'partner' => array('_id' => (string) UserSession::get('user._id'), 'name' => UserSession::get('user.name'))))));
 }
Example #9
0
 public function index()
 {
     Url::redirect(UserSession::get('user.type') . '/home');
 }
Example #10
0
 protected function _view($id)
 {
     $notify = new Notify();
     $n = $notify->get(new \MongoId($id), true, UserSession::get('user._id'));
     Url::redirect(empty($n['url']) ? Url::referrer() : $n['url']);
 }
Example #11
0
 public function post()
 {
     Url::redirect(Url::base('influencer/river/' . $this->input->post('id') ?: ''));
 }