2

I am drying to deploy HyBridAuth as a plugin in my website . my fucntion looks something like this .

function authenticatewith( $provider ){
                                    ini_set('display_errors','on');

            //includes

                    $config   = dirname(__FILE__) . '/hybridauth-2.1.2/hybridauth/config.php';
                                require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );

                            $provider_name = $provider;

                            //$config = $this->getconfig($id);
                            try{
                            // initialize Hybrid_Auth with a given file
                            $hybridauth = new Hybrid_Auth( $config );

                            // try to authenticate with the selected provider
                            $adapter = $hybridauth->authenticate( $provider_name );

                            // then grab the user profile 
                            $user_profile = $adapter->getUserProfile();
                            }
                            catch( Exception $e ){
                            echo "Error: please try again!";
                            echo "Original error message: " . $e->getMessage();
                            }

                            echo "USer Details: ";
                            var_dump($user_profile);

            }   

I am running into a fatal error when I try to access any of the provider .

Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php on line 165

I get no links for this problem in stack I though I will raise this here.

Thanks & Regards

Vikram Anand Bhushan
  • 4,368
  • 12
  • 46
  • 118

5 Answers5

3

Before doing anything else, make sure you are using session_start().

Since using session_start() will throw an error of level E_NOTICE if a session has already been started, a better approach would be:

if(session_id() == '') {
    session_start();
}

And keep in mind that if the user's browser does not have cookies enabled, you will have issues with HybridAuth because of the default value of the PHP setting session.use_cookies

session.use_cookies = 1 //PHP uses cookies by default

A beta user for a project I'm working on reported seeing this error - and for a long time I was unable to replicate the error. After long hours of debugging, it turned out to be a browser configuration error that was specific to the user (cookies were disabled). Not sure if it will solve your problem, but it's worth mentioning that the error:

Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php 

Can also be caused due to browser-specific settings (such as disabled cookies).

References:

http://php.net/manual/en/function.session-start.php

http://php.net/manual/en/session.security.php

oblivion02
  • 402
  • 4
  • 11
1

This error occur if you cannot access the config.php or if the base_url is wrong or if you are trying to access the remote application service ( facebook , or else ) from localhost... You should then use a live domaine working online , to do so you have to add the following line to your windows/system32/drivers/etc/hosts if you are under windows and /etc/hosts if you are in unix based system :

127.0.0.1 your-domaine.extension

where extension is one of the following : com , net or anything else that could work

this method is applied if you have not a working domain for your application otherwise you need to specify your www domain for this to work properly...

hope its helpfull

Shabasha
  • 31
  • 2
  • I am using MAMP so I have the setup like www.domain.dev and also in config. The error is still there. – Shina Mar 09 '15 at 11:10
  • your www.domain.dev should be added to your hosts file as described not only in web server configuration ... when you update your hosts file ... try to restart your system or your network service ... be sure that there is no firewall running or it will block HTTP requests coming from outside ... once done , in your browser address bar , type : www.domain.dev and it must redirect you to your localhost document root ... if so then you can connect your application to facebook , twitter or google using Hybrid_Auth ... – Shabasha Mar 25 '15 at 15:36
  • if it is not be sure that the base_url you specified in your Hybrid_Auth is the same as you redirect URL and / or CallBack URL you configured in your application settings , or you will fail ... – Shabasha Mar 25 '15 at 15:37
1

I had the exact same error, I discovered that the session global variable didn't have the required values ("CONFIG") and it was because I set the base_url to a different than the one from which I was testing. To be more specific: I was accessing with www.mywebsite.com and the base_url was set to just mywebsite.com. Fixed it by setting base_url to www.mywebsite.com. I also recommend to redirect to www like this: .htaccess - how to force "www." in a generic way?

Community
  • 1
  • 1
josue.0
  • 500
  • 1
  • 8
  • 18
  • The error is still there even with www, I doubt this is the problem – Shina Mar 09 '15 at 11:08
  • @Shina did you change the authorized redirection URI's in your provider developer website (i.e.: Google Console Developers)? – josue.0 Mar 10 '15 at 15:25
  • I think I did, e.g. on Twitter ... I have all domain set to www.domainname.dev and same for FB. Am I missing something else? – Shina Mar 10 '15 at 20:43
0
require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );

does not contain the full path like the include of config.php does.

SenseException
  • 885
  • 10
  • 14
  • I have not written the complete url . But In my program its correct . I was fed up of with the errors . So I changed my Hydrauth files back to an older version . Now I am getting "Page cannot be accesed error" – Vikram Anand Bhushan Nov 07 '14 at 12:34
0

Use session_start(); before any other things you do..

Charly
  • 1