Php 使用google openid登录CodeIgniter
我是CodeIgniter框架的新手。我已经尝试使用openid登录,因为我复制了lightopenid url并将其放在config/config.php中Php 使用google openid登录CodeIgniter,php,codeigniter,Php,Codeigniter,我是CodeIgniter框架的新手。我已经尝试使用openid登录,因为我复制了lightopenid url并将其放在config/config.php中 $config['base_url'] = 'https://gitorious.org/lightopenid/lightopenid/raw/9d42dc24e4dd34121c98a6491bc3ef7933a68a19:openid.php'; A PHP Error was encountered Severi
$config['base_url'] = 'https://gitorious.org/lightopenid/lightopenid/raw/9d42dc24e4dd34121c98a6491bc3ef7933a68a19:openid.php';
A PHP Error was encountered
Severity: Warning
Message: require(openid.php): failed to open stream: No such file or directory
Filename: models/login_model.php
Line Number: 2
请在下面找到我使用的代码
Controllers/logingogle.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LoginGoogle extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('login_model');
}
public function index()
{
require_once 'openid.php';
$openid = new LightOpenID("localhost");
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array(
'namePerson/first',
'namePerson/last',
'contact/email',
'birthDate',
'person/gender',
'contact/postalCode/home',
'contact/country/home',
'pref/language',
'pref/timezone',
);
$openid->returnUrl = 'http://localhost/login_thirdparty/codeigniterlogin/index.php/logingoogle/loginAuth';
$data['openid'] = $openid;
$this->load->view('googleLoginView', $data);
}
public function loginAuth()
{
$this->login_model->index();
}
}
models/login_model.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require 'openid.php';
class Login_model extends CI_Model
{
public function index()
{
$openid = new LightOpenID("localhost");
if($openid->mode)
{
if($openid->mode == 'cancel')
{
echo "User has canceled authentication !";
}
elseif($openid->validate())
{
$data = $openid->getAttributes();
$email = $data['contact/email'];
$first = $data['namePerson/first'];
echo "Identity : $openid->identity <br />";
echo "Email : $email <br />";
echo "First name : $first";
echo "<pre>"; print_r($data); echo "</pre>";
}
else
{
echo "The user has not logged in";
}
}
else
{
echo "Go to the login page to logged in";
}
}
}
views/googleLoginView.php
错误原因是需要“openid.php”。您没有放入openid.php文件,或者在模型类和控制器类中都找不到该文件
最好是直接在netbeans的源文件中创建一个文件夹作为openid文件夹,并在其上创建一个php文件。复制下面链接的代码,并将其粘贴到您创建的空白php文件中
在控制器和模型中,您必须将require'openid.php'更改为require opened/openid.php
希望它能起作用
<html lang="en">
<head>
<title>Login using google account</title>
</head>
<body>
<a href = "<?php echo $openid->authUrl(); ?>" > Loging Using google account </a>
</body>
</html>