source: extensions/oAuth/include/test/examples/widget_authentication/mywebsite/index.php @ 20293

Last change on this file since 20293 was 20293, checked in by mistic100, 11 years ago

first commit of oAuth plugin, still in developpement

File size: 1.4 KB
Line 
1<?php
2    # start a new PHP session
3    session_start();
4
5        // we need to know it
6        $CURRENT_URL = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
7       
8        // change the following paths if necessary
9        $config   = dirname(__FILE__) . '/../../../hybridauth/config.php';
10        require_once( "../../../hybridauth/Hybrid/Auth.php" );
11
12        try{
13                $hybridauth = new Hybrid_Auth( $config );
14        }
15        catch( Exception $e ){
16                echo "Ooophs, we got an error: " . $e->getMessage();
17        }
18
19        $provider = ""; 
20       
21        // handle logout request
22        if( isset( $_GET["logout"] ) ){
23                $provider = $_GET["logout"];
24
25                $adapter = $hybridauth->getAdapter( $provider );
26
27                $adapter->logout();
28               
29                header( "Location: index.php"  );
30               
31                die();
32        }
33
34        // if the user select a provider and authenticate with it
35        // then the widget will return this provider name in "connected_with" argument
36        elseif( isset( $_GET["connected_with"] ) && $hybridauth->isConnectedWith( $_GET["connected_with"] ) ){
37                $provider = $_GET["connected_with"];
38               
39                $adapter = $hybridauth->getAdapter( $provider );
40               
41                $user_data = $adapter->getUserProfile();
42
43                // include authenticated user view
44                include "inc_authenticated_user.php";
45               
46                die();
47        } // if user connected to the selected provider
48
49        // if not, include unauthenticated user view
50        include "inc_unauthenticated_user.php";
Note: See TracBrowser for help on using the repository browser.