1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | FacebookPlug - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2010-2011 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 | define('FACEBOOKPLUG_ROOT_PATH','./'); |
---|
22 | |
---|
23 | require_once 'include/common.php'; |
---|
24 | |
---|
25 | // Check argument |
---|
26 | !empty($_GET['filename']) or trigger_error('Missing argument!', E_USER_ERROR); |
---|
27 | |
---|
28 | /*try |
---|
29 | { |
---|
30 | //~ $fbme = null; |
---|
31 | $uid = $facebook->getUser(); |
---|
32 | $fbme = $facebook->api('/me'); |
---|
33 | |
---|
34 | $param = array( |
---|
35 | 'method' => 'users.getinfo', |
---|
36 | //~ 'uids' => $fbme['id'], |
---|
37 | 'uids' => $uid, |
---|
38 | 'fields' => 'name,current_location,profile_url', |
---|
39 | 'callback' => '' |
---|
40 | ); |
---|
41 | $userInfo = $facebook->api($param); |
---|
42 | d($userInfo); |
---|
43 | } |
---|
44 | catch (FacebookApiException $e) |
---|
45 | { |
---|
46 | d($e); |
---|
47 | }*/ |
---|
48 | |
---|
49 | fbp_mkdir($conf['local_upload_dir']); |
---|
50 | |
---|
51 | //~ try { |
---|
52 | //~ $statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> $fbme['name'].' a mis à jour son status par Piwigo en test sur FB', 'cb' => '')); |
---|
53 | //~ echo "Status mis à jour"; |
---|
54 | //~ } catch (FacebookApiException $e) { |
---|
55 | //~ d($e); |
---|
56 | //~ } |
---|
57 | |
---|
58 | //~ try { |
---|
59 | //~ $result = $facebook->api('/me/albums', 'post', array('name' => 'Piwigo', 'message'=> 'Test')); |
---|
60 | //~ d($result); |
---|
61 | //~ echo "Album créé"; |
---|
62 | //~ } catch (FacebookApiException $e) { |
---|
63 | //~ d($e); |
---|
64 | //~ } |
---|
65 | |
---|
66 | $filename = $_GET['filename']; |
---|
67 | $local_filename = $conf['local_upload_dir'].'/'.basename($filename); |
---|
68 | |
---|
69 | @unlink($local_filename); |
---|
70 | |
---|
71 | @set_time_limit(0); |
---|
72 | |
---|
73 | //~ copy($filename, $local_filename); |
---|
74 | if ($handle = @fopen($local_filename, 'wb') and fbp_fetchRemote($filename, $handle)) |
---|
75 | { |
---|
76 | fclose($handle); |
---|
77 | } |
---|
78 | |
---|
79 | if (is_file($local_filename)) |
---|
80 | { |
---|
81 | try |
---|
82 | { |
---|
83 | $facebook->setFileUploadSupport(true); |
---|
84 | //~ $result = $facebook->api('/me/photos', 'post', array('source' => '@./tmp/_upload/'.basename($local_filename))); |
---|
85 | $result = $facebook->api('/me/photos', 'post', array('source' => '@'.$local_filename)); |
---|
86 | //~ d($result); |
---|
87 | unlink($local_filename); |
---|
88 | } |
---|
89 | catch (FacebookApiException $e) |
---|
90 | { |
---|
91 | d($e); |
---|
92 | } |
---|
93 | |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | trigger_error('$filename not uploaded', E_USER_ERROR); |
---|
98 | } |
---|
99 | |
---|
100 | // check extension |
---|
101 | // changer le nom de l'image |
---|
102 | |
---|
103 | ?> |
---|