mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-07 00:48:55 +00:00
fbpost/fbsync: make the neccessary calls, so that "Leistungsschutzrecht" can be invoked.
This commit is contained in:
parent
f0ccc16165
commit
225aabf5bb
2 changed files with 69 additions and 68 deletions
|
@ -985,7 +985,8 @@ function fbpost_cleanpicture($url) {
|
|||
function fbpost_fetchwall($a, $uid) {
|
||||
require_once("include/oembed.php");
|
||||
require_once("include/network.php");
|
||||
require_once('mod/item.php');
|
||||
require_once("include/items.php");
|
||||
require_once("mod/item.php");
|
||||
|
||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||
$post_to_page = get_pconfig($uid,'facebook','post_to_page');
|
||||
|
@ -1043,13 +1044,16 @@ function fbpost_fetchwall($a, $uid) {
|
|||
|
||||
$_REQUEST["body"] = (isset($item->message) ? escape_tags($item->message) : '');
|
||||
|
||||
$pagedata = array();
|
||||
$content = "";
|
||||
$type = "";
|
||||
$pagedata["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;
|
||||
$pagedata["type"] = $oembed_data->type;
|
||||
$pagedata["url"] = $item->link;
|
||||
$pagedata["title"] = $item->name;
|
||||
$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.
|
||||
|
@ -1061,75 +1065,71 @@ function fbpost_fetchwall($a, $uid) {
|
|||
} elseif (isset($item->name))
|
||||
$content .= "[b]".$item->name."[/b]";
|
||||
|
||||
$quote = "";
|
||||
$pagedata["text"] = "";
|
||||
if(isset($item->description) and ($item->type != "photo"))
|
||||
$quote = $item->description;
|
||||
$pagedata["text"] = $item->description;
|
||||
|
||||
if(isset($item->caption) and ($item->type == "photo"))
|
||||
$quote = $item->caption;
|
||||
$pagedata["text"] = $item->caption;
|
||||
|
||||
// Only import the picture when the message is no video
|
||||
// oembed display a picture of the video as well
|
||||
//if ($item->type != "video") {
|
||||
//if (($item->type != "video") and ($item->type != "photo")) {
|
||||
if (($type == "") OR ($type == "link")) {
|
||||
if (($pagedata["type"] == "") OR ($pagedata["type"] == "link")) {
|
||||
|
||||
$type = $item->type;
|
||||
$pagedata["type"] = $item->type;
|
||||
|
||||
if (isset($item->picture))
|
||||
$picture = $item->picture;
|
||||
$pagedata["images"][0]["src"] = $item->picture;
|
||||
|
||||
if (($type == "photo") AND isset($item->object_id)) {
|
||||
if (($pagedata["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;
|
||||
$pagedata["images"][0]["src"] = $data->images[0]->source;
|
||||
logger('fbpost_fetchwall: got fbid image '.$preview, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
if(trim($_REQUEST["body"].$content.$quote) == '') {
|
||||
if(trim($_REQUEST["body"].$content.$pagedata["text"]) == '') {
|
||||
logger('facebook: empty body 2 '.$item->id.' '.print_r($item, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
$picture = fbpost_cleanpicture($picture);
|
||||
$pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]);
|
||||
|
||||
if(($picture != "") && isset($item->link)) {
|
||||
if(($pagedata["images"][0]["src"] != "") && isset($item->link)) {
|
||||
$item->link = original_url($item->link);
|
||||
$content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]';
|
||||
$pagedata["url"] = $item->link;
|
||||
$content .= "\n".'[url='.$item->link.'][img]'.$pagedata["images"][0]["src"].'[/img][/url]';
|
||||
} else {
|
||||
if ($picture != "")
|
||||
$content .= "\n".'[img]'.$picture.'[/img]';
|
||||
if ($pagedata["images"][0]["src"] != "")
|
||||
$content .= "\n".'[img]'.$pagedata["images"][0]["src"].'[/img]';
|
||||
// if just a link, it may be a wall photo - check
|
||||
if(isset($item->link))
|
||||
$content .= fbpost_get_photo($uid,$item->link);
|
||||
}
|
||||
}
|
||||
|
||||
if(trim($_REQUEST["body"].$content.$quote) == '') {
|
||||
if(trim($_REQUEST["body"].$content.$pagedata["text"]) == '') {
|
||||
logger('facebook: empty body '.$item->id.' '.print_r($item, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= "\n";
|
||||
if ($pagedata["type"] != "")
|
||||
$_REQUEST["body"] .= add_page_info_data($pagedata);
|
||||
else {
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= "\n".trim($content);
|
||||
|
||||
if ($type)
|
||||
$_REQUEST["body"] .= "[class=type-".$type."]";
|
||||
if ($pagedata["text"])
|
||||
$_REQUEST["body"] .= "\n[quote]".$pagedata["text"]."[/quote]";
|
||||
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= trim($content);
|
||||
|
||||
if ($quote)
|
||||
$_REQUEST["body"] .= "\n[quote]".$quote."[/quote]";
|
||||
|
||||
if ($type)
|
||||
$_REQUEST["body"] .= "[/class]";
|
||||
|
||||
$_REQUEST["body"] = trim($_REQUEST["body"]);
|
||||
$_REQUEST["body"] = trim($_REQUEST["body"]);
|
||||
}
|
||||
|
||||
if (isset($item->place)) {
|
||||
if ($item->place->name or $item->place->location->street or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue