protected function _save() { try { $influencer = new Influencer(UserSession::get('user._id')); $iinfo = $influencer->get(); $accounts = array(); if ($a = MongoDoc::get($iinfo, 'social.twitter')) { $accounts['twitter'] = $a['user_id']; } if ($a = MongoDoc::get($iinfo, 'social.google-plus')) { $accounts['gplus'] = $a['id']; } if ($a = MongoDoc::get($iinfo, 'social.instagram')) { $accounts['instagram'] = $a['id']; } $sdk = new kl\SDK(); $me = null; foreach ($accounts as $k => $id) { try { switch ($k) { case 'twitter': $me = $sdk->getIdentityTwitterId($id); break; case 'instagram': $me = $sdk->getIdentityInstagramId($id); break; case 'gplus': $me = $sdk->getIdentityGooglePlusId($id); break; } break; } catch (\Exception $e) { $me = null; } } if (!$me) { Alert::once('error', 'Failed to add Klout account: No social accounts were detected on the Klout profile', Url::base('influencer/social')); } $me = $sdk->getUser($me['id']); $influencer->update(array('social.klout' => $me)); } 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_klout($u, &$info, $social) { try { $sdk = new kl\SDK(); $info = $sdk->getUser($info['kloutId']); } catch (\Exception $e) { $this->_notify_invalidate($u['_id'], $social); } }