我已经通过我的 CodeIngiter 应用程序成功访问了 LinkedIn API。我搬到了几乎相同的服务器并实现了 i18n 库,但它停止了工作。
用户在 LinkedIn 上进行身份验证后,它会返回到正确的 URL,但会生成一系列以Undefined index: oauth_verifier
使用i18n 库后,我的 URL 现在在第一段中有两个字母语言代码,例如“en”或“br”。
编辑:这是我正在使用的Linkedin 库。
我相信这会导致 $_REQUEST['oath_verifier'] 的设置出现路由问题
非常感谢您对此的任何帮助。
控制器摘录:
class LinkLogin extends MY_Controller {
function __construct(){
parent::__construct();
$this->load->helper('url');
$this->load->model('profile_model');
$this->load->model('generic_model');
include_once (APPPATH.'libraries/Linkedin.php');
}
function index(){
}
function initiate(){
session_start();
$this->load->helper('url');
$config['linkedin_access'] = "***";
$config['linkedin_secret'] = "***";
$config['base_url'] = "http://www.youinapage.com/linklogin/initiate/";
if ($this->uri->segment(4) == 'profile') {
$config['callback_url'] = "http://www.youinapage.com/linklogin/get_profile_linkedin/";
}
if ($this->uri->segment(4) == 'resume') {
$config['callback_url'] = "http://www.youinapage.com/linklogin/get_resume_linkedin/";
}
function get_resume_linkedin() {
session_start();
$this->load->library('format');
$config['linkedin_access'] = "***";
$config['linkedin_secret'] = "***";
$config['base_url'] = "http://www.youinapage.com/linklogin/initiate/";
$config['callback_url'] = "http://www.youinapage.com/linklogin/get_resume_linkedin/";
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url'] );
//$linkedin->debug = true;
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url'] );
//$linkedin->debug = true;
if (isset($_REQUEST['oauth_verifier'])){
$_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
$linkedin->getAccessToken($_REQUEST['oauth_verifier']);
$_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
header("Location: " . $config['callback_url']);
exit;
}
else{
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier']; // ERROR: Undefined index: oauth_verifier
$linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
}