3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 require_once INSTALLDIR.'/extlib/facebook/facebook.php';
21 require_once INSTALLDIR.'/lib/noticelist.php';
23 define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
24 define("FACEBOOK_NOTICE_PREFIX", 1);
25 define("FACEBOOK_PROMPTED_UPDATE_PREF", 2);
27 // Gets all the notices from users with a Facebook link since a given ID
28 function get_facebook_notices($since)
30 $qry = 'SELECT notice.* ' .
32 'JOIN foreign_link ' .
33 'WHERE notice.profile_id = foreign_link.user_id ' .
34 'AND foreign_link.service = 2';
36 // XXX: What should the limit be?
37 return Notice::getStreamDirect($qry, 0, 100, 0, 0, null, $since);
40 function get_facebook()
42 $apikey = common_config('facebook', 'apikey');
43 $secret = common_config('facebook', 'secret');
44 return new Facebook($apikey, $secret);
47 function startFBML($indent = true)
50 $xw = new XMLWriter();
51 $xw->openURI('php://output');
52 $xw->setIndent($indent);
55 function getFacebookBaseCSS()
57 # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
58 $ts = filemtime(INSTALLDIR.'/theme/base/css/facebookapp.base.css');
59 $cssurl = INSTALLDIR.'/theme/base/css/facebookapp.base.css' . "?ts=$ts";
63 function getFacebookThemeCSS()
65 # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
66 $ts = filemtime(theme_file('css/facebookapp.theme.css'));
67 $cssurl = theme_path('css/facebookapp.theme.css') . "?ts=$ts";
71 function getFacebookJS() {
73 # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes
74 $ts = filemtime(INSTALLDIR.'/js/facebookapp.js');
75 $jsurl = common_path('js/facebookapp.js') . "?ts=$ts";