]> git.mxchange.org Git - friendica-addons.git/blobdiff - fbpost/fbpost.php
Setting "editplain", "page" and "privacy_image_cache" as deprecated. Using new cache...
[friendica-addons.git] / fbpost / fbpost.php
index f4f29f1e827987c203a07999e97f9d4ba4ab0a81..2ac558ea8def501329e32c1b58dafceffebadb4f 100644 (file)
@@ -564,7 +564,7 @@ function fbpost_post_hook(&$a,&$b) {
 
                                if ($toplevel) {
                                        require_once("include/plaintext.php");
-                                       $msgarr = plaintext($a, $b, 0, false);
+                                       $msgarr = plaintext($a, $b, 0, false, 9);
                                        $msg = $msgarr["text"];
                                        $link = $msgarr["url"];
                                        $linkname = $msgarr["title"];
@@ -1032,6 +1032,13 @@ function fbpost_fetchwall($a, $uid) {
                        $oembed_data = oembed_fetch_url($item->link);
                        $type = $oembed_data->type;
                        $content = "[bookmark=".$item->link."]".$item->name."[/bookmark]";
+
+                       // If a link is not only attached but also added in the body, look if it can be removed in the body.
+                       $removedlink = trim(str_replace($item->link, "", $_REQUEST["body"]));
+
+                       if (($removedlink == "") OR strstr($_REQUEST["body"], $removedlink))
+                               $_REQUEST["body"] = $removedlink;
+
                } elseif (isset($item->name))
                        $content .= "[b]".$item->name."[/b]";
 
@@ -1050,11 +1057,25 @@ function fbpost_fetchwall($a, $uid) {
 
                        $type = $item->type;
 
-                       if(isset($item->picture) && isset($item->link))
-                               $content .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]';
+                       if (isset($item->picture))
+                               $picture = $item->picture;
+
+                       if (($type == "photo") AND isset($item->object_id)) {
+                                logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG);
+                               $url = "https://graph.facebook.com/".$item->object_id."?access_token=".$access_token;
+                               $feed = fetch_url($url);
+                               $data = json_decode($feed);
+                               if (isset($data->images)) {
+                                       $picture = $data->images[0]->source;
+                                       logger('fbpost_fetchwall: got fbid image '.$preview, LOGGER_DEBUG);
+                               }
+                       }
+
+                       if(($picture != "") && isset($item->link))
+                               $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]';
                        else {
-                               if (isset($item->picture))
-                                       $content .= "\n".'[img]'.fpost_cleanpicture($item->picture).'[/img]';
+                               if ($picture != "")
+                                       $content .= "\n".'[img]'.$picture.'[/img]';
                                // if just a link, it may be a wall photo - check
                                if(isset($item->link))
                                        $content .= fbpost_get_photo($uid,$item->link);
@@ -1125,7 +1146,7 @@ function fbpost_get_photo($uid,$link) {
        $x = fetch_url('https://graph.facebook.com/'.$photo_id.'?access_token='.$access_token);
        $j = json_decode($x);
        if($j->picture)
-               return "\n\n".'[url='.$link.'][img]'.fpost_cleanpicture($j->picture).'[/img][/url]';
+               return "\n\n".'[url='.$link.'][img]'.$j->picture.'[/img][/url]';
 
        return "";
 }