2017-05-17 4 views
0

codeigniter를 사용하여 linkedin api로 로그인하려고합니다. 내 코드는 다음과 같습니다.Codeigniter를 사용하여 LinkedIn API로 로그인 하시겠습니까?

컨트롤러

<?php 
class User extends CI_Controller 
{ 
    function __construct() 
    { 
     parent::__construct(); 
     $this->load->library('session'); 
    } 
    function index() 
    { 
     echo anchor('user/login', 'Sign in with Linkedin'); 
    } 
    function login() 
    { 
     $data['api_key'] = "xxxxxxxx"; 
     $data['api_secret'] = "xxxxxxx"; 
     $data['callback_url'] = base_url()."user/login"; 
     $this->load->library("LinkedIn",$data); 
     //echo $data['callback_url']; 
     $linked = new LinkedIn($data); 
     $url = urldecode($linked->getLoginUrl(
     array(
    LinkedIn::SCOPE_BASIC_PROFILE, 
    LinkedIn::SCOPE_EMAIL_ADDRESS, 
) 
     )); 
     //echo $url; 
     if(isset($_GET['code'])) 
     { 
     $code = $_GET['code']; 
     $access_token = $linked->getAccessToken($code); 
     $token_expires = $linked->getAccessTokenExpiration(); 
     $linked->setAccessToken($access_token); 
     //$user=$linked->get('v1/people/~:(firstName,lastName)','get',$access_token); 
     //$info = $linked->get('/people/~:(first-name,last-name,company,positions)'); 
     $profile_fileds = array(
      'id', 
      'firstName', 
      'maiden-name', 
      'lastName', 
      'picture-url', 
      'email-address', 
      'location:(country:(code))', 
      'industry', 
      'summary', 
      'specialties', 
      'interests', 
      'public-profile-url', 
      'last-modified-timestamp', 
      'num-recommenders', 
      'date-of-birth', 
     ); 
     $profileData = $linked->get('/people/~:(' . implode(',', $profile_fileds) . ')'); 
     var_dump($profileData); 
     } 
     else 
     { 
      redirect($url); 
     } 
    } 
    function cancel() 
    { 
     echo "canecl by user"; 
    } 

} 

내 코드가 제대로 작동하지만 난 페이지를 새로 고칠 때, 나에게 내가했던 그

Type: RuntimeException Message: Access Token Request Error: invalid_request -- missing required >parameters, includes an invalid parameter value, parameter more than once. : >Unable to retrieve access token : appId or redirect uri does not match >authorization code or authorization code expired

답변

0

같은 errror 줄에 access_token이 추가 처음 그런 세션.

if($this->session->userdata('token)) 
{ 
$linked->setaccesstoken($this->session->userdata('token)); 
} 
else{ 
/////same codepaste here 
} 
관련 문제