- if ($item->type != "video") {
- //if (($item->type != "video") and ($item->type != "photo")) {
- if(isset($item->picture) && isset($item->link))
- $_REQUEST["body"] .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]';
- else {
- if (isset($item->picture))
- $_REQUEST["body"] .= "\n".'[img]'.fpost_cleanpicture($item->picture).'[/img]';
+ //if ($item->type != "video") {
+ //if (($item->type != "video") && ($item->type != "photo")) {
+ if (($pagedata["type"] == "") || ($pagedata["type"] == "link")) {
+
+ $pagedata["type"] = $item->type;
+
+ if (isset($item->picture))
+ $pagedata["images"][0]["src"] = $item->picture;
+
+ if (($pagedata["type"] == "photo") && 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)) {
+ $pagedata["images"][0]["src"] = $data->images[0]->source;
+ logger('got fbid image from images for '.$item->object_id, LOGGER_DEBUG);
+ } elseif (isset($data->source)) {
+ $pagedata["images"][0]["src"] = $data->source;
+ logger('got fbid image from source for '.$item->object_id, LOGGER_DEBUG);
+ } elseif (isset($data->picture)) {
+ $pagedata["images"][0]["src"] = $data->picture;
+ logger('got fbid image from picture for '.$item->object_id, LOGGER_DEBUG);
+ }
+ }
+
+ if(trim($_REQUEST["body"].$content.$pagedata["text"]) == '') {
+ logger('facebook: empty body 1 '.$item->id.' '.print_r($item, true));
+ continue;
+ }
+
+ $pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]);
+
+ if(($pagedata["images"][0]["src"] != "") && isset($item->link)) {
+ $item->link = original_url($item->link);
+ $pagedata["url"] = $item->link;
+ $content .= "\n".'[url='.$item->link.'][img]'.$pagedata["images"][0]["src"].'[/img][/url]';
+ } else {
+ if ($pagedata["images"][0]["src"] != "")
+ $content .= "\n".'[img]'.$pagedata["images"][0]["src"].'[/img]';