Я пытаюсь войти в систему с помощью API-интерфейса linkedin с помощью codeigniter. Мой код выглядит следующим образом.
Контроллер
<?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";
}
}
В первый раз мой код работал правильно, но когда я обновляю страницу, он дает мне такую ошибку
Тип: RuntimeException Сообщение: Ошибка запроса токена доступа: invalid_request -- отсутствуют обязательные > параметры, включает недопустимое значение параметра, параметр более одного раза. : >Невозможно получить токен доступа: appId или URI перенаправления не совпадают >код авторизации или срок действия кода авторизации истек