PHP code example of org_heigl / hybridauth

1. Go to this page and download the library: Download org_heigl/hybridauth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

org_heigl / hybridauth example snippets


    return [
        'OrgHeiglHybridAuth' => [
            'socialAuth' => [
                'redirectUri' => 'http://localhost:8080/authenticate/backend',
                'provider' => [
                    'twitter' => [
                        'applicationId' => '',
                        'applicationSecret' => '',
                        'scope' => ['email'],
                    ],
                    'github' => [
                        'applicationId' => '',
                        'applicationSecret' => '',
                        'scope' => ['email'],
                    ],
                ],
            ],
            'session_name' => 'orgheiglhybridauth',
            'backend'         => array('Twitter'), // could also be ['Twitter', 'Facebook']
            // 'link'            => '<a class="hybridauth" href="%2$s">%1$s</a>', // Will be either inserted as first parameter into item or simply returned as complete entry
            // 'item'            => '<li%2$s>%1$s</li>',
            // 'itemlist'        => '<ul%2$s>%1$s</ul>',
            // 'logincontainer'  => '<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">%1$s<b class="caret"></b></a>%2$s</li>',
            // 'logoffcontainer' => '<li>%1$s</li>',
            // 'logoffstring'    => 'Logout %1$s',
            // 'loginstring'     => 'Login%1$s',
            // 'listAttribs'     => null, // Will be inserted as 2nd parameter into item
            // 'itemAttribs'     => null, // Will be inserted as 2nd parameter into itemlist
        ]
    ];
    

    
    $provider = "Twitter";
    echo $this->hybridauthinfo($provider);
    

    $config = $this->getServiceLocator()->get('Config');
    $config = $config['OrgHeiglHybridAuth'];
    $hybridAuth = new Hybridauth($config['hybrid_auth']);

    $token = $this->getServiceLocator()->get('OrgHeiglHybridAuthToken');
    if (! $token->isAuthenticated()) {
        echo 'No user logged in';
    }
    /** @var OrgHeiglHybridAuth\UserToken $user */
    echo $token->getDisplayName(); // The name of the logged in user
    echo $token->getUID();  // The internal UID of the used service
    echo $token->getMail(); // The mail-address the service provides
    echo $token->getLanguage(); // The language the service provides for the user
    echo $token->getService()  // Should print out the Name of the service provider.