diff options
author | Friendika <info@friendika.com> | 2011-04-28 19:19:36 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-04-28 19:19:36 -0700 |
commit | 4e4c002006f7903448cd533fbf32911056fe400f (patch) | |
tree | 85dbb0c36045b94b95b2e70a2fc18e794e725f61 /addon/facebook/facebook.php | |
parent | b43ed54967e133ca250ee7f42a90d699781d904f (diff) | |
download | volse-hubzilla-4e4c002006f7903448cd533fbf32911056fe400f.tar.gz volse-hubzilla-4e4c002006f7903448cd533fbf32911056fe400f.tar.bz2 volse-hubzilla-4e4c002006f7903448cd533fbf32911056fe400f.zip |
slightly better handling of photos and links for FB.
Diffstat (limited to 'addon/facebook/facebook.php')
-rw-r--r-- | addon/facebook/facebook.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index c7821b272..f6f830435 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -442,10 +442,22 @@ function facebook_post_hook(&$a,&$b) { // make links readable before we strip the code + if(preg_match("/\[url=(.+?)\](.+?)\[\/url\]/is",$msg,$matches)) { + + $link = $matches[1]; + if(substr($matches[2],0,5) != '[img]' ) + $linkname = $matches[2]; + } + $msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 $1',$msg); + if(preg_match("/\[img\](.+?)\[\/img\]/is",$msg,$matches)) + $image = $matches[1]; + $msg = preg_replace("/\[img\](.+?)\[\/img\]/is", t('Image: ') . '$1', $msg); + + $msg = trim(strip_tags(bbcode($msg))); $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8'); @@ -478,6 +490,12 @@ function facebook_post_hook(&$a,&$b) { 'access_token' => $fb_token, 'message' => $msg ); + if(isset($image)) + $postvars['picture'] = $image; + if(isset($link)) + $postvars['link'] = $link; + if(isset($linkname)) + $postvars['name'] = $linkname; } if(($b['private']) && (! $b['parent'])) { @@ -490,17 +508,15 @@ function facebook_post_hook(&$a,&$b) { } - if(! $reply) { - if($b['plink']) - $postvars['actions'] = '{"name": "' . t('View on Friendika') . '", "link": "' . $b['plink'] . '"}'; - } - if($reply) { $url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments'); } else { $url = 'https://graph.facebook.com/me/feed'; + if($b['plink']) + $postvars['actions'] = '{"name": "' . t('View on Friendika') . '", "link": "' . $b['plink'] . '"}'; } + logger('facebook: post to ' . $url); logger('facebook: postvars: ' . print_r($postvars,true)); |