]> git.mxchange.org Git - friendica-addons.git/commitdiff
fbpost/fbsync: Better picture support for facebook. Now the highest resolution is...
authorMichael Vogel <icarus@dabo.de>
Sun, 27 Jul 2014 14:07:30 +0000 (16:07 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 27 Jul 2014 14:07:30 +0000 (16:07 +0200)
fbpost/fbpost.php
fbsync/fbsync.php
privacy_image_cache/privacy_image_cache.php

index b0e383e46232db287410b39ae9b6d148b9b4787c..c5b7918315f2508b1d7a80c9272df623217a87a1 100644 (file)
@@ -1050,11 +1050,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/v2.0/".$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 +1139,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 "";
 }
index fc9d7c187db0ed2b5254737cc3b94437e39cc01c..e558cb9ac4d2daf035668fe168ff53a4e7759d29 100644 (file)
@@ -213,6 +213,8 @@ function fbsync_expire($a,$b) {
 
 function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
 
+       $access_token = get_pconfig($uid,'facebook','access_token');
+
        require_once("include/oembed.php");
 
        // check if it was already imported
@@ -365,10 +367,22 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
                        if (isset($media->src))
                                $preview = $media->src;
 
-                       if (isset($media->photo))
+                       if (isset($media->photo)) {
                                if (isset($media->photo->images) AND (count($media->photo->images) > 1))
                                        $preview = $media->photo->images[1]->src;
 
+                               if (isset($media->photo->fbid)) {
+                                       logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG);
+                                       $url = "https://graph.facebook.com/v2.0/".$media->photo->fbid."/?access_token=".$access_token;
+                                       $feed = fetch_url($url);
+                                       $data = json_decode($feed);
+                                       if (isset($data->images)) {
+                                               $preview = $data->images[0]->source;
+                                               logger('fbsync_createpost: got fbid image '.$preview, LOGGER_DEBUG);
+                                       }
+                               }
+                       }
+
                        if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
                                $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
                        else {
index 0a6d8be1de3002614f0d5eef44a6080deb8bb68e..930fab538cdac73843eadff2320f2dd64d5f5466 100644 (file)
@@ -307,8 +307,8 @@ function privacy_image_cache_img_cb($matches) {
                $matches[2] = urldecode($queryvar['url']);
 
        // if fetching facebook pictures don't fetch the thumbnail but the big one
-       if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg"))
-               $matches[2] = substr($matches[2], 0, -6)."_n.jpg";
+       //if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg"))
+       //      $matches[2] = substr($matches[2], 0, -6)."_n.jpg";
 
        // following line changed per bug #431
        if (privacy_image_cache_is_local_image($matches[2]))