]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/facebookutil.php
Merge branch 'master' of evan@dev.controlyourself.ca:/var/www/trunk
[quix0rs-gnu-social.git] / lib / facebookutil.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 require_once INSTALLDIR.'/extlib/facebook/facebook.php';
21 require_once INSTALLDIR.'/lib/noticelist.php';
22
23 define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
24 define("FACEBOOK_NOTICE_PREFIX", 1);
25 define("FACEBOOK_PROMPTED_UPDATE_PREF", 2);
26
27 // Gets all the notices from users with a Facebook link since a given ID
28 function get_facebook_notices($since)
29 {
30     $qry = 'SELECT notice.* ' .
31         'FROM notice ' .
32         'JOIN foreign_link ' .
33         'WHERE notice.profile_id = foreign_link.user_id ' .
34         'AND foreign_link.service = 2';
35
36     // XXX: What should the limit be?
37     return Notice::getStreamDirect($qry, 0, 100, 0, 0, null, $since);
38 }
39
40 function get_facebook()
41 {
42     $apikey = common_config('facebook', 'apikey');
43     $secret = common_config('facebook', 'secret');
44     return new Facebook($apikey, $secret);
45 }
46
47 function startFBML($indent = true)
48 {
49     global $xw;
50     $xw = new XMLWriter();
51     $xw->openURI('php://output');
52     $xw->setIndent($indent);
53 }
54
55 function getFacebookBaseCSS()
56 {
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";
60     return $cssurl;
61 }
62
63 function getFacebookThemeCSS() 
64 {
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";
68     return $cssurl;   
69 }
70
71 function getFacebookJS() {
72
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";
76     return $jsurl;
77 }
78