Exemplo n.º 1
0
 protected function _attach()
 {
     try {
         $sdk = new tw\SDK();
         if ($session = $sdk->obtainToken(Url::base('brand/social/twitter/' . UserSession::get('user._id')))) {
             $sdk = new tw\SDK($session['oauth_token'], $session['oauth_token_secret']);
             $account = $session;
             $account['details'] = $sdk->getProfile();
             $brand = new Brand(UserSession::get('user._id'));
             $brand->modify(array('_id' => $brand->id), array('$set' => array('social.twitter' => $account), '$pull' => array('social_invalidated' => 'twitter')));
         }
     } catch (tw\TwitterAccessTokenException $e) {
         Alert::once('error', 'Failed to add account: ' . $e->getMessage(), Url::base('brand/social'));
     }
     Alert::once('success', 'Account added successfully', Url::base('brand/social'));
 }
Exemplo n.º 2
0
 protected function _fetch_twitter($u, &$info, $social)
 {
     try {
         $sdk = new tw\SDK($info['oauth_token'], $info['oauth_token_secret']);
         $info['details'] = $sdk->getProfile();
     } catch (tw\TwitterAccessTokenException $e) {
         $this->_notify_invalidate($u['_id'], $social);
     }
 }