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
25 // Gets all the notices from users with a Facebook link since a given ID
26 function get_facebook_notices($since)
28 $qry = 'SELECT notice.* ' .
30 'JOIN foreign_link ' .
31 'WHERE notice.profile_id = foreign_link.user_id ' .
32 'AND foreign_link.service = 2';
34 // XXX: What should the limit be?
35 return Notice::getStreamDirect($qry, 0, 100, 0, 0, null, $since);
38 function get_facebook()
40 $apikey = common_config('facebook', 'apikey');
41 $secret = common_config('facebook', 'secret');
42 return new Facebook($apikey, $secret);
45 function start_fbml($indent = true)
48 $xw = new XMLWriter();
49 $xw->openURI('php://output');
50 $xw->setIndent($indent);
53 function update_profile_box($facebook, $fbuid, $user, $notice)
56 // Need to include inline CSS for styling the Profile box
63 list-style-type: none;
65 border-top: 1px solid #dec5b5;
68 text-decoration: underline;
74 padding: 5px 5px 5px 0;
76 font-family: Georgia, "Times New Roman", Times, serif;
79 border-bottom: 1px solid #dec5b5;
80 background-color:#FCFFF5;
83 .notice_single:hover {
84 background-color: #f7ebcc;
94 $xw = new XMLWriter();
97 $item = new NoticeListItem($notice);
100 $fbml = "<fb:wide>$style " . $xw->outputMemory(false) . "</fb:wide>";
101 $fbml .= "<fb:narrow>$style " . $xw->outputMemory(false) . "</fb:narrow>";
103 $fbml_main = "<fb:narrow>$style " . $xw->outputMemory(false) . "</fb:narrow>";
105 $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);