से पहले कोड openid.php पर डाउनलोड करें और अपने कोडिनेटर रूट फ़ोल्डर में डालें।
1. प्रतिलिपि कोड और के रूप में बचाने के लिए ..../नियंत्रक/logingoogle.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/login_google.php';
$openid->returnUrl = 'http://localhost/login_thirdparty/codeigniterlogin/index.php/logingoogle/loginAuth';
// echo '<a href="'.$openid->authUrl().'">Login with Google</a>';
$data['openid'] = $openid;
$this->load->view('googleLoginView', $data);
}
public function loginAuth()
{
$this->login_model->index();
}
}
2. प्रतिलिपि कोड और के रूप में ..../विचारों/googleLoginView.php बचाने
<!DOCTYPE html>
<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>
3. प्रतिलिपि कोड और के रूप में बचाने के लिए ..../मॉडल/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'];
// header("Location: http://speechwithmilo.com/speechtherapy/adminpanel/");
echo "Identity : $openid->identity <br />";
echo "Email : $email <br />";
echo "First name : $first";
echo "<pre>"; print_r($data); echo "</pre>";
// echo "<meta http-equiv = 'refresh' content = '0; url=http://speechwithmilo.com/speechtherapy/adminpanel/'>";
}
else
{
echo "The user has not logged in";
}
}
else
{
echo "Go to the login page to logged in";
}
}
}
स्रोत
2013-06-18 11:41:56
ध्यान रखें कि अप्रैल 2015 से Google ने ओपनआईडी कनेक्ट के साथ लॉगिन के पक्ष में ओपनआईडी के साथ लॉगिन रद्द कर दिया है, यह एक बहुत ही अलग उत्तराधिकारी है, यह भी देखें: https://developers.google.com/identity/protocols/OpenID2 माइग्रेशन –