public function auth() { $linkedIn = new Happyr\LinkedIn\LinkedIn(LI_CLIENT_ID, LI_SECRET_KEY); if ($linkedIn->isAuthenticated()) { $access_token = $linkedIn->getAccessToken(); $user = $linkedIn->get('v1/people/~:(id)'); $user_account = array('user_id' => $this->user->id, 'account_id' => $user['id'], 'type' => 'linkedin', 'access_token' => $access_token->getToken()); $this->load->model('user_account_model'); if ($this->user_account_model->save($user_account)) { redirect(base_url() . "main/myaccount/linkedin"); } } exit("Something went wrong."); }
public function post_linkedin($options, $access_token) { $result['success'] = false; try { $linkedIn = new Happyr\LinkedIn\LinkedIn(LI_CLIENT_ID, LI_SECRET_KEY); $linkedIn->setAccessToken($access_token); $body = $linkedIn->post('v1/people/~/shares', $options); if (isset($body['updateKey'])) { $result['success'] = true; $result['link'] = $body['updateUrl']; } } catch (Exception $e) { $result['error'] = $e->getMessage(); } return $result; }