]> git.mxchange.org Git - friendica-addons.git/commitdiff
Facebook: Messages without images and links but with a subject and a text larger...
authorMichael Vogel <icarus@dabo.de>
Fri, 13 Apr 2012 06:32:17 +0000 (08:32 +0200)
committerMichael Vogel <icarus@dabo.de>
Fri, 13 Apr 2012 06:32:17 +0000 (08:32 +0200)
facebook/facebook.php

index 6b9ee73623dc28d2076e7b2d6d6aae71d88ee162..a90445db57a9802b2a13cee1f9c8474e06887dfa 100755 (executable)
@@ -1009,10 +1009,14 @@ function facebook_post_hook(&$a,&$b) {
                                                'access_token' => $fb_token, 
                                                'message' => $msg
                                        );
-                                       if(isset($image))
+                                       if(isset($image)) {
                                                $postvars['picture'] = $image;
-                                       if(isset($link))
+                                               //$postvars['type'] = "photo";
+                                       }
+                                       if(isset($link)) {
                                                $postvars['link'] = $link;
+                                               //$postvars['type'] = "link";
+                                       }
                                        if(isset($linkname))
                                                $postvars['name'] = $linkname;
                                }
@@ -1029,11 +1033,18 @@ function facebook_post_hook(&$a,&$b) {
 
                                if($reply) {
                                        $url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
-                               }
-                               else { 
+                               } else if (($link != "")  or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) { 
                                        $url = 'https://graph.facebook.com/me/feed';
                                        if($b['plink'])
                                                $postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' .  $b['plink'] . '"}';
+                               } else {
+                                       // if its only a message and a subject and the message is larger than 500 characters then post it as note
+                                       $postvars = array(
+                                               'access_token' => $fb_token, 
+                                               'message' => bbcode($b['body']),
+                                               'subject' => $b['title'],
+                                       );
+                                       $url = 'https://graph.facebook.com/me/notes';
                                }
 
                                logger('facebook: post to ' . $url);