From d3987416c50396fdb4881240f15b563a68c43ab6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 17 Dec 2010 22:36:35 -0800 Subject: [PATCH] facebook connector - initial checkin (untested) --- mod/item.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mod/item.php b/mod/item.php index ea88e6c311..99721794a1 100644 --- a/mod/item.php +++ b/mod/item.php @@ -323,10 +323,42 @@ function item_post(&$a) { proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$notify_type\" \"$post_id\" &", array(),$foo)); + /** + * Post to Facebook stream + */ + + if((local_user()) && (local_user() == $profile_uid)) { + $appid = get_config('system', 'facebook_appid' ); + $secret = get_config('system', 'facebook_secret' ); + if($appid && $secret) { + $fb_post = get_pconfig($local_user(),'facebook','post'); + if($fb_post) { + require_once('library/facebook.php'); + require_once('include/bbcode.php'); + + $facebook = new Facebook(array( + 'appId' => $appid, + 'secret' => $secret, + 'cookie' => true + )); + try { + $statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> bbcode($body), 'cb' => '')); + } + catch (FacebookApiException $e) { + notice( t('Facebook status update failed.') . EOL); + } + } + } + } + goaway($a->get_baseurl() . "/" . $_POST['return'] ); return; // NOTREACHED } + + + + function item_content(&$a) { if((! local_user()) && (! remote_user()))