From 76a8623053ae12e4dcb0e63c58e5a14d0a46ba62 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 14 Oct 2014 19:32:31 +0200 Subject: [PATCH 1/3] Facebook: The system now tries to get the full resolution of an imported post. Additionally URLs are cleaned from tracking variables. --- fbpost/fbpost.php | 21 +++++++++++++++++++-- fbsync/fbsync.php | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 2ac558ea..38fe1920 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -967,8 +967,21 @@ function fbpost_cron($a,$b) { set_config('facebook','last_poll', time()); } +function fbpost_cleanpicture($url) { + require_once("include/Photo.php"); + + $urldata = parse_url($url); + if (isset($urldata["query"])) { + parse_str($urldata["query"], $querydata); + if (isset($querydata["url"]) AND (get_photo_info($querydata["url"]))) + return($querydata["url"]); + } + return($url); +} + function fbpost_fetchwall($a, $uid) { require_once("include/oembed.php"); + require_once("include/network.php"); require_once('mod/item.php'); $access_token = get_pconfig($uid,'facebook','access_token'); @@ -1029,6 +1042,7 @@ function fbpost_fetchwall($a, $uid) { $type = ""; if(isset($item->name) and isset($item->link)) { + $item->link = original_url($item->link); $oembed_data = oembed_fetch_url($item->link); $type = $oembed_data->type; $content = "[bookmark=".$item->link."]".$item->name."[/bookmark]"; @@ -1071,9 +1085,12 @@ function fbpost_fetchwall($a, $uid) { } } - if(($picture != "") && isset($item->link)) + $picture = fbpost_cleanpicture($picture); + + if(($picture != "") && isset($item->link)) { + $item->link = original_url($item->link); $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]'; - else { + } else { if ($picture != "") $content .= "\n".'[img]'.$picture.'[/img]'; // if just a link, it may be a wall photo - check diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index 51d2747f..64f6fe2a 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -216,6 +216,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr $access_token = get_pconfig($uid,'facebook','access_token'); require_once("include/oembed.php"); + require_once("include/network.php"); // check if it was already imported $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", @@ -339,6 +340,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr $type = ""; if (isset($post->attachment->name) and isset($post->attachment->href)) { + $post->attachment->href = original_url($post->attachment->href); $oembed_data = oembed_fetch_url($post->attachment->href); $type = $oembed_data->type; if ($type == "rich") @@ -391,6 +393,8 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr } } + $preview = fbpost_cleanpicture($preview); + if (isset($media->href) AND ($preview != "") AND ($media->href != "")) $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]'; else { From 39cc0fe4cb909a52b3bb75b685ca7142863a6027 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Oct 2014 00:05:06 +0200 Subject: [PATCH 2/3] Bugfix: Sometimes it happened that the own contact data was deleted. This was caused by the statusnet connector. --- statusnet/statusnet.php | 9 ++++----- twitter/twitter.php | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index c3591356..e96a8967 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -872,6 +872,9 @@ function statusnet_address($contact) { } function statusnet_fetch_contact($uid, $contact, $create_user) { + if ($contact->statusnet_profile_url == "") + return(-1); + // Check if the unique contact is existing // To-Do: only update once a while $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", @@ -950,16 +953,12 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', - `name-date` = '%s', - `uri-date` = '%s', `avatar-date` = '%s' WHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), intval($contact_id) ); @@ -971,7 +970,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { // check that we have all the photos, this has been known to fail on occasion - if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) { + if((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) { logger("statusnet_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG); diff --git a/twitter/twitter.php b/twitter/twitter.php index 1919e28c..2669c46d 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -892,6 +892,9 @@ function twitter_queue_hook(&$a,&$b) { function twitter_fetch_contact($uid, $contact, $create_user) { require_once("include/Photo.php"); + if ($contact->id_str == "") + return(-1); + $avatar = str_replace("_normal.", ".", $contact->profile_image_url_https); $info = get_photo_info($avatar); From 8c5ee7e062451dcf4262616456979c67a1bba52f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Oct 2014 00:26:06 +0200 Subject: [PATCH 3/3] Removed some stuff from another branch --- fbpost/fbpost.php | 21 ++------------------- fbsync/fbsync.php | 4 ---- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 38fe1920..2ac558ea 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -967,21 +967,8 @@ function fbpost_cron($a,$b) { set_config('facebook','last_poll', time()); } -function fbpost_cleanpicture($url) { - require_once("include/Photo.php"); - - $urldata = parse_url($url); - if (isset($urldata["query"])) { - parse_str($urldata["query"], $querydata); - if (isset($querydata["url"]) AND (get_photo_info($querydata["url"]))) - return($querydata["url"]); - } - return($url); -} - function fbpost_fetchwall($a, $uid) { require_once("include/oembed.php"); - require_once("include/network.php"); require_once('mod/item.php'); $access_token = get_pconfig($uid,'facebook','access_token'); @@ -1042,7 +1029,6 @@ function fbpost_fetchwall($a, $uid) { $type = ""; if(isset($item->name) and isset($item->link)) { - $item->link = original_url($item->link); $oembed_data = oembed_fetch_url($item->link); $type = $oembed_data->type; $content = "[bookmark=".$item->link."]".$item->name."[/bookmark]"; @@ -1085,12 +1071,9 @@ function fbpost_fetchwall($a, $uid) { } } - $picture = fbpost_cleanpicture($picture); - - if(($picture != "") && isset($item->link)) { - $item->link = original_url($item->link); + if(($picture != "") && isset($item->link)) $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]'; - } else { + else { if ($picture != "") $content .= "\n".'[img]'.$picture.'[/img]'; // if just a link, it may be a wall photo - check diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index 64f6fe2a..51d2747f 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -216,7 +216,6 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr $access_token = get_pconfig($uid,'facebook','access_token'); require_once("include/oembed.php"); - require_once("include/network.php"); // check if it was already imported $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", @@ -340,7 +339,6 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr $type = ""; if (isset($post->attachment->name) and isset($post->attachment->href)) { - $post->attachment->href = original_url($post->attachment->href); $oembed_data = oembed_fetch_url($post->attachment->href); $type = $oembed_data->type; if ($type == "rich") @@ -393,8 +391,6 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr } } - $preview = fbpost_cleanpicture($preview); - if (isset($media->href) AND ($preview != "") AND ($media->href != "")) $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]'; else {