diff options
author | Friendika <info@friendika.com> | 2010-12-27 23:28:34 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2010-12-27 23:28:34 -0800 |
commit | caf93fffac2aa87966bfafdc8bd7adfd3a07dce8 (patch) | |
tree | 8e1a0a93b2f89cd261dbcaed8e0e99ec298ec55b /addon/facebook/facebook.php | |
parent | bdc4cd63e1a80a89c68fe70cb05dd23dcd7f9645 (diff) | |
download | volse-hubzilla-caf93fffac2aa87966bfafdc8bd7adfd3a07dce8.tar.gz volse-hubzilla-caf93fffac2aa87966bfafdc8bd7adfd3a07dce8.tar.bz2 volse-hubzilla-caf93fffac2aa87966bfafdc8bd7adfd3a07dce8.zip |
move facebook post to addon - and under the AGPL
Diffstat (limited to 'addon/facebook/facebook.php')
-rw-r--r-- | addon/facebook/facebook.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php new file mode 100644 index 000000000..df2f86d3a --- /dev/null +++ b/addon/facebook/facebook.php @@ -0,0 +1,50 @@ +<?php + + +function facebook_install() { + register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); +} + + +function facebook_uninstall() { + unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); +} + + + + +function facebook_post_hook(&$a,&$b) { + + /** + * Post to Facebook stream + */ + + if((local_user()) && (local_user() == $b['uid']) && (! $b['private'])) { + + $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($datarray['body']), 'cb' => '')); + } + catch (FacebookApiException $e) { + notice( t('Facebook status update failed.') . EOL); + } + } + } + } + +}
\ No newline at end of file |