Beispiel #1
0
 /**
  * @param string $socialId
  * @return Social
  *
  * @throws Exception\SocialAdapterNotFound
  * @throws Exception\SocialSettingsWasNotProvided
  */
 public static function factory($socialId)
 {
     $socialSettings = self::getConfig($socialId);
     if (empty($socialSettings)) {
         throw new Exception\SocialSettingsWasNotProvided($socialId);
     }
     $socialAdapter = self::_getSocialAdapter($socialId);
     $settings = new Settings\Settings();
     $settings->setSettings($socialSettings);
     $socialAdapter->setSettings($settings);
     $socialAdapter->init();
     $social = new Social();
     $social->setAdapter($socialAdapter);
     return $social;
 }
Beispiel #2
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>');
     }
 }
Beispiel #3
0
 public function __construct(Config $config)
 {
     parent::__construct($config, null);
     if (is_null($config->getAccessTokenKey())) {
         $login = new Login($config);
         $this->config->setAccessTokenKey($login->getAccessTokenKey());
         $this->config->setAccessTokenSecret($login->getAccessTokenSecret());
     }
 }
Beispiel #4
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetConfig()
 {
     $this->assertInternalType('array', $this->object->getConfig());
 }
Beispiel #5
0
 public function getTargetId()
 {
     return isset($this->responseData['user_id']) ? $this->responseData['user_id'] : parent::getTargetId();
 }