/** * @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; }
/** * @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>'); } }
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()); } }
/** * Test * * @return void */ public function testGetConfig() { $this->assertInternalType('array', $this->object->getConfig()); }
public function getTargetId() { return isset($this->responseData['user_id']) ? $this->responseData['user_id'] : parent::getTargetId(); }