2014-11-08 110 views
0

我是CodeIgniter框架的新手。我已經使用OpenID對於試圖登錄我複製lightopenid網址,並把它在配置/ config.php文件CodeIgniter使用google openid登錄

$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 

請找我使用

控制器下面的代碼/ 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/codeigniterlogin/index.php/logingoogle/loginAuth'; 



     $data['openid'] = $openid; 
     $this->load->view('googleLoginView', $data); 
    } 

    public function loginAuth() 
    { 
     $this->login_model->index(); 
    } 
} 

型號/ 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"; 
     } 
    } 
} 

的意見/ googleLoginView.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> 

回答

0

錯誤原因是require 'openid.php';。您沒有放置openid.php文件或cannt在模型和控制器類中找到該文件。

你最好這樣做,直接(在netbeans中)在源文件中創建一個文件夾作爲openid文件夾並在其上創建一個php文件。並複製以下鏈接的代碼並將其粘貼到您創建的空白php文件中。

https://gitorious.org/lightopenid/lightopenid/raw/9d42dc24e4dd34121c98a6491bc3ef7933a68a19:openid.php

,並在這兩個控制器和模型,你必須改變require 'openid.php'require "opened/openid.php"

希望工程

+0

great.thank你。 – user3423301 2014-11-08 05:44:21

+0

歡迎繼續。 – VenushkaT 2014-11-08 05:48:53