示例#1
0
 /**
  * @method GET
  * @api connect
  */
 public function connect()
 {
     $userID = User::getID();
     $appID = Social::getSettings('appID');
     $appSecret = Social::getSettings('appSecret');
     $facebook = new Facebook(array('appId' => $appID, 'secret' => $appSecret));
     // Get User ID
     $user = $facebook->getUser();
     if ($user) {
         try {
             $user_profile = $facebook->api('/me');
         } catch (FacebookApiException $e) {
             $user = null;
         }
         $db = DB::instance();
         $data = $db->select('facebook', array('facebookID' => $user_profile['id']));
         //
         if (count($data) == 0) {
             $db->insert('facebook', array('userID' => $userID, 'facebookID' => $user_profile['id']));
         }
         die('<script>window.close()</script>');
     } else {
         $params = array('redirect_uri' => 'http://localhost/openfantasy/web/facebook/connect', 'scope' => 'email');
         die('<script>top.location.href="' . $facebook->getLoginUrl($params) . '";</script>');
     }
 }
示例#2
0
 /**
  * @method GET
  * @api get
  */
 public function get()
 {
     $userID = isset($_GET['userID']) ? $_GET['userID'] : User::getID();
     $db = DB::instance();
     $data = $db->select('users', array('userID' => $userID), 1);
     return $this->response($data);
 }
示例#3
0
 /**
  * @method GET
  * @api name
  */
 public function name()
 {
     // if not logged in, getID is 0 (anonymous)
     Analytics::track('saidhello', 'HelloWorld', User::getID());
     return $this->response(array('status' => 1, 'message' => "Hello " . $_GET['myName'] . "!"));
 }