source: extensions/oAuth/include/test/examples/social_hub/timeline.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: 3.0 KB
Line 
1<?php
2        // config and whatnot
3        $config = dirname(__FILE__) . '/../../hybridauth/config.php';
4        require_once( "../../hybridauth/Hybrid/Auth.php" );
5
6        // initialise hybridauth
7        $hybridauth = new Hybrid_Auth( $config );
8
9        // selected provider name
10        $provider = @ trim( strip_tags( $_GET["provider"] ) );
11
12        // check if the user is currently connected to the selected provider
13        if( !  $hybridauth->isConnectedWith( $provider ) ){ 
14                // redirect him back to login page
15                header( "Location: login.php?error=Your are not connected to $provider or your session has expired" );
16        }
17
18        // Common functions and utilities
19        include "includes/common.php"; 
20?>
21<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
22<html lang="en">
23<head>
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
25<link rel="stylesheet" href="public/css.css" type="text/css"> 
26</head>
27<body> 
28<table width="90%" border="0" cellpadding="2" cellspacing="2">
29  <tr>
30    <td valign="top">
31                <?php
32                        include "includes/menu.php"; 
33                ?> 
34                <fieldset>
35                        <legend>Timeline</legend>
36                        <table width="100%">
37<?php
38        try{
39                // call back the requested provider adapter instance
40                $adapter = $hybridauth->getAdapter( $provider );
41
42                // grab the user timeline
43                $user_activity = $adapter->getUserActivity( "timeline" );
44               
45                foreach( $user_activity as $item ){
46                        ?>
47                                <tr>
48                                        <td align="left" valign="top" width="55" > 
49                                                <?php
50                                                        if( $item->user->photoURL ){
51                                                ?>
52                                                                <a href="<?php echo $item->user->profileURL; ?>"><img src="<?php echo $item->user->photoURL; ?>" border="0" width="48" height="48"></a>
53                                                <?php
54                                                        }
55                                                        else{
56                                                ?> 
57                                                                <a href="<?php echo $item->user->profileURL; ?>"><img src="public/avatar.png" width="48" height="48" ></a>
58                                                <?php
59                                                        } 
60                                                ?> 
61                                        </td>
62                                        <td align="left"> 
63                                                <a href="<?php echo $item->user->profileURL; ?>"><b><?php echo $item->user->displayName; ?></b></a> <small>(ID:<?php echo $item->user->identifier; ?>)</small><br />
64                                                <?php echo format_string( $item->text ); ?>
65                                                <br /><small><?php echo timestamp_to_relative_time( $item->date ); ?></small>
66                                                <hr />
67                                        </td>
68                                </tr>
69                        <?php
70                }
71
72                if( ! count( $user_activity ) ){
73                        echo "No activity found!";
74                }
75        }
76        catch( Exception $e ){
77                // if code 8 => Provider does not support this feature
78                if( $e->getCode() == 8 ){
79                        echo "Provider does not support this feature. Currently only <b>Facebook, MySpace, Twitter and LinkedIn</b> do support this!
80                        <br />Please refer to the user guide to know more about each adapters capabilities. <a href='http://hybridauth.sourceforge.net/userguide.html'>http://hybridauth.sourceforge.net/userguide.html</a>";
81                }
82                else{
83                        echo "Well, got an error: " . $e->getMessage();
84                } 
85        } 
86?>
87                        </table>
88      </fieldset>
89        </td>
90    <td valign="top" width="250" align="left">
91                <?php
92                        include "includes/sidebar.php";
93                ?>
94        </td>
95  </tr>
96</table>
97</body>
98</html>
Note: See TracBrowser for help on using the repository browser.