.
 */
require_once(INSTALLDIR.'/extlib/facebook/facebook.php');
require_once(INSTALLDIR.'/lib/noticelist.php');
define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
// Gets all the notices from users with a Facebook link since a given ID
function get_facebook_notices($since)
{
    $qry = 'SELECT notice.* ' .
        'FROM notice ' .
        'JOIN foreign_link ' .
        'WHERE notice.profile_id = foreign_link.user_id ' .
        'AND foreign_link.service = 2';
    // XXX: What should the limit be?
    return Notice::getStreamDirect($qry, 0, 100, 0, 0, null, $since);
}
function get_facebook()
{
    $apikey = common_config('facebook', 'apikey');
    $secret = common_config('facebook', 'secret');
    return new Facebook($apikey, $secret);
}
function start_fbml($indent = true)
{
    global $xw;
    $xw = new XMLWriter();
    $xw->openURI('php://output');
    $xw->setIndent($indent);
}
function update_profile_box($facebook, $fbuid, $user, $notice)
{
    // Need to include inline CSS for styling the Profile box
    $style = '';
    global $xw;
    $xw = new XMLWriter();
    $xw->openMemory();
    $item = new NoticeListItem($notice);
    $item->show();
    $fbml = "$style " . $xw->outputMemory(false) . "";
    $fbml .= "$style " . $xw->outputMemory(false) . "";
    $fbml_main = "$style " . $xw->outputMemory(false) . "";
    $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
}