![Picture of Alpesh Prajapati Picture of Alpesh Prajapati](/graphics/unknown.gif)
Alpesh Prajapati - 2019-04-30 16:22:30
Hello there
i want am using this literary in Codeigniter for sing in with Linked in with oauth 1.0 and now my client want to change this to oauth 2.0 with linked in latest api
so can you tell me what changes i need to do in http_class.php and Oauth_client_class.php to use oauth 2.0 with latest APi
this is my previous code
$this->load->library('http_class');
$this->load->library('oauth_client_class');
$baseURL = base_url();
$callbackURL = base_url('/linkedin/process');
$linkedinApiKey = 'APIKEY';
$linkedinApiSecret = 'SECREAT';
$linkedinScope = 'r_basicprofile r_emailaddress';
if (isset($_GET["oauth_problem"]) && $_GET["oauth_problem"] <> "") {
// in case if user cancel the login. redirect back to home page.
//$_SESSION["err_msg"] = $_GET["oauth_problem"];
echo $_GET["oauth_problem"];
// header("location:index.php");
exit;
}
$this->oauth_client_class->debug = false;
$this->oauth_client_class->debug_http = true;
$this->oauth_client_class->redirect_uri = $callbackURL;
$this->oauth_client_class->client_id = $linkedinApiKey;
$application_line = __LINE__;
$this->oauth_client_class->client_secret = $linkedinApiSecret;
if (strlen($this->oauth_client_class->client_id) == 0 || strlen($this->oauth_client_class->client_secret) == 0)
die('Please go to LinkedIn Apps page https://www.linkedin.com/secure/developer?newapp= , '.
'create an application, and in the line '.$application_line.
' set the client_id to Consumer key and client_secret with Consumer secret. '.
'The Callback URL must be '.$this->oauth_client_class->redirect_uri).' Make sure you enable the '.
'necessary permissions to execute the API calls your application needs.';
/* API permissions
*/
$this->oauth_client_class->scope = $linkedinScope;
if (($success = $this->oauth_client_class->Initialize())) {
if (($success = $this->oauth_client_class->Process())) {
if (strlen($this->oauth_client_class->authorization_error)) {
$this->oauth_client_class->error = $this->oauth_client_class->authorization_error;
$success = false;
} elseif (strlen($this->oauth_client_class->access_token)) {
$success = $this->oauth_client_class->CallAPI(
'http://api.linkedin.com/v1/people/~:(id,email-address,first-name,last-name,location,picture-url,public-profile-url,formatted-name,positions,headline)',
'GET', array(
'format'=>'json'
), array('FailOnAccessError'=>true), $user);
}
}
$success = $this->oauth_client_class->Finalize($success);
}
if ($this->oauth_client_class->exit) exit;
if ($success) {
/*process data*/
}
so can you tell me how can i use Linked in latest API and what i need to change in class files
Thanks and regards