1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | FacebookPlug - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2010 Ruben ARNAUD - rub@piwigo.org | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | This program is free software; you can redistribute it and/or modify | |
---|
7 | // | it under the terms of the GNU General Public License as published by | |
---|
8 | // | the Free Software Foundation | |
---|
9 | // | | |
---|
10 | // | This program is distributed in the hope that it will be useful, but | |
---|
11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | // | General Public License for more details. | |
---|
14 | // | | |
---|
15 | // | You should have received a copy of the GNU General Public License | |
---|
16 | // | along with this program; if not, write to the Free Software | |
---|
17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | // | USA. | |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | |
---|
21 | defined('FACEBOOKPLUG_ROOT_PATH') or trigger_error('Hacking attempt!', E_USER_ERROR); |
---|
22 | |
---|
23 | require_once(FACEBOOKPLUG_ROOT_PATH . 'include/constants.php'); |
---|
24 | require_once(FACEBOOKPLUG_ROOT_PATH . 'include/constants_secret.php'); |
---|
25 | require_once(FACEBOOKPLUG_ROOT_PATH . 'include/facebook.php'); |
---|
26 | require_once(FACEBOOKPLUG_ROOT_PATH . 'include/functions.php'); |
---|
27 | |
---|
28 | // Main global var |
---|
29 | $conf = array(); |
---|
30 | |
---|
31 | // Default config |
---|
32 | include(FACEBOOKPLUG_ROOT_PATH . 'include/config_default.php'); |
---|
33 | |
---|
34 | // Init Facebook |
---|
35 | $facebook = new Facebook(array( |
---|
36 | 'appId' => FACEBOOK_APP_ID, |
---|
37 | 'secret' => FACEBOOK_SECRET, |
---|
38 | 'cookie' => true, // enable optional cookie support |
---|
39 | )); |
---|
40 | |
---|
41 | //~ print_r($_COOKIE); |
---|
42 | |
---|
43 | |
---|
44 | function d($d) |
---|
45 | { |
---|
46 | echo '<pre>'; |
---|
47 | print_r($d); |
---|
48 | echo '</pre>'; |
---|
49 | } |
---|
50 | |
---|
51 | $session = $facebook->getSession(); |
---|
52 | // Session based graph API call. |
---|
53 | if (! $session) |
---|
54 | { |
---|
55 | // Redirect to facebook page reconnect |
---|
56 | $url = $facebook->getLoginUrl( |
---|
57 | array |
---|
58 | ( |
---|
59 | //ici on demande les permissions email, publication sur le mur, et changement du status |
---|
60 | 'req_perms' => 'email,publish_stream,status_update', |
---|
61 | )); |
---|
62 | header( 'Request-URI: '.$url ); |
---|
63 | header( 'Content-Location: '.$url ); |
---|
64 | header( 'Location: '.$url ); |
---|
65 | exit(); |
---|
66 | } |
---|
67 | |
---|
68 | ?> |
---|