Opauth和Codeigniter致命错误:无法访问空属性

时间:2014-06-28 14:05:04

标签: codeigniter oauth twitter-oauth

我使用库Opauth进行社交认证。 在授权时滑动错误

  

致命错误:无法在第1095行的/%my_directory%/system/core/Loader.php中访问空属性

请告诉我这个错误有什么关系。

ci_opauth.php

 $config['opauth_config'] = array(
            'path' => '/oauth/login/', //example: /ci_opauth/auth/login/
            'callback_url' => '/oauth/authenticate/', //example: /ci_opauth/auth/authenticate/
            'callback_transport' => 'post', //Codeigniter don't use native session
            'security_salt' => 'Salt',
            'debug' => false,
            'Strategy' => array( //comment those you don't use
                                'Twitter' => array(
                                'key' => 'key',
                                'secret' = 'secret_key',
                    'name' => 'Twitter',
                    'description' => 'Войти с помощью twitter.com',
                    'tabimg' => "<img src=/assets/img/social-buttons/blank.gif width=16px height=16px style='background-position: 0 476px';>",
                    'signinimg' => "<img src=/assets/img/social-buttons/blank.gif width=89px height=21px style='background-position: 0 -42px';>"
                                                 )
                                       )
                                             )
                                           );

oauth.php

public function login(){
        //Comprobate if the user request a strategy
        if($this->uri->segment(3)==''){
            $ci_config = $this->config->item('opauth_config');
            $arr_strategies = array_keys($ci_config['Strategy']);

            echo("Please, select an Oauth provider:<br />");
            echo("<ul>");
            foreach($arr_strategies AS $strategy){
                echo("<li><a href='".base_url()."oauth/login/".strtolower($strategy)."'>Login with ".$strategy."</li>");
            }
            echo("</ul>");
        }   
        else{
            //Run login
            $this->load->library('Opauth/Opauth', $this->config->item('opauth_config'), false);
            $this->opauth->run();    
        }     
    }

    function authenticate(){
        //Create authenticate logic
        $response = unserialize(base64_decode( $_POST['opauth'] ));
        echo("<pre>");
        print_r($response);
        echo("</pre>");
    }

如果您需要提供更多信息,请回答我的问题,请告诉我

1 个答案:

答案 0 :(得分:0)

如果加载程序不起作用,您可以使用经典require

require(APPPATH .'libraries/Opauth/Opauth.php');

$opauth = new Opauth($this->config->item('opauth_config'));