protected function _save() { try { $sdk = new vn\SDK($this->input->post('username'), $this->input->post('password')); $me = $sdk->getUserMe(); $me['credentials'] = array('username' => $this->input->post('username'), 'password' => $this->input->post('password')); $influencer = new Influencer(UserSession::get('user._id')); $influencer->modify(array('_id' => $influencer->id), array('$set' => array('social.vine' => $me), '$pull' => array('social_invalidated' => 'vine'))); } catch (\Exception $e) { Alert::once('error', 'Failed to add account: ' . $e->getMessage(), Url::base('influencer/social')); } Alert::once('success', 'Account added successfully', Url::base('influencer/social')); }
protected function _fetch_vine($u, &$info, $social) { try { $creds = $info['credentials']; $sdk = new vn\SDK($creds['username'], $creds['password']); $info = $sdk->getUserMe(); $info['credentials'] = $creds; } catch (\Exception $e) { $this->_notify_invalidate($u['_id'], $social); } }