$o .= '<div id="fbpost-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
- . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_stream,manage_pages,photo_upload,user_groups,offline_access">' . t('Install Facebook Post connector for this account.') . '</a>';
+ . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access">' . t('Install Facebook Post connector for this account.') . '</a>';
$o .= '</div>';
}
$o .= '<div id="fbpost-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
- . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_stream,manage_pages,photo_upload,user_groups,offline_access">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
+ . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
$o .= '</div>';
$o .= '<div id="fbpost-post-default-form">';
if($b['deleted'] || ($b['created'] !== $b['edited']))
return;
+ // Don't transmit answers (have to be cleaned up in the following code)
+ if($b['parent'] != $b['id'])
+ return;
+
// if post comes from facebook don't send it back
if($b['app'] == "Facebook")
return;
function fbpost_fetchwall($a, $uid) {
$access_token = get_pconfig($uid,'facebook','access_token');
+ $post_to_page = get_pconfig($uid,'facebook','post_to_page');
$lastcreated = get_pconfig($uid,'facebook','last_created');
- $lastcreated = "";
- $url = 'https://graph.facebook.com/me/feed?access_token='.$access_token;
+ if ((int)$post_to_page == 0)
+ $post_to_page = "me";
+
+ $url = "https://graph.facebook.com/".$post_to_page."/feed?access_token=".$access_token;
+
+ $first_time = ($lastcreated == "");
if ($lastcreated != "")
$url .= "&since=".urlencode($lastcreated);
$feed = fetch_url($url);
$data = json_decode($feed);
+
+ if (!is_array($data->data))
+ return;
+
$items = array_reverse($data->data);
foreach ($items as $item) {
if ($item->created_time > $lastcreated)
$lastcreated = $item->created_time;
+ if ($first_time)
+ continue;
+
if ($item->application->id == get_config('facebook','appid'))
continue;
- if(isset($item->privacy) && $item->privacy->value !== 'EVERYONE')
+ if(isset($item->privacy) && ($item->privacy->value !== 'EVERYONE') && ($item->privacy->value !== ''))
continue;
+ if (($post_to_page != $item->from->id) AND ((int)$post_to_page != 0))
+ continue;
$_SESSION["authenticated"] = true;
$_SESSION["uid"] = $uid;
elseif (isset($item->name))
$_REQUEST["body"] .= "\n\n[b]" . $item->name."[/b]";
- if(isset($item->caption)) {
+ /*if(isset($item->caption)) {
if(!isset($item->name) and isset($item->link))
$_REQUEST["body"] .= "\n\n[bookmark=".$item->link."]".$item->caption."[/bookmark]";
//else
$_REQUEST["body"] .= "\n[url]".$item->link."[/url]\n";
else
$_REQUEST["body"] .= "\n";
- }
+ }*/
$quote = "";
- if(isset($item->description))
+ if(isset($item->description) and ($item->type != "photo"))
$quote = $item->description;
- if (isset($item->properties))
- foreach ($item->properties as $property)
- $quote .= "\n".$property->name.": [url=".$property->href."]".$property->text."[/url]";
+ if(isset($item->caption) and ($item->type == "photo"))
+ $quote = $item->caption;
+
+ //if (isset($item->properties))
+ // foreach ($item->properties as $property)
+ // $quote .= "\n".$property->name.": [url=".$property->href."]".$property->text."[/url]";
if ($quote)
$_REQUEST["body"] .= "\n[quote]".$quote."[/quote]";
// 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(isset($item->picture) && isset($item->link))
$_REQUEST["body"] .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]';
else {
}
}
- if (($datarray['app'] == "Events") and isset($item->actions))
+ /*if (($datarray['app'] == "Events") and isset($item->actions))
foreach ($item->actions as $action)
if ($action->name == "View")
$_REQUEST["body"] .= " [url=".$action->link."]".$item->story."[/url]";
+ */
if(trim($_REQUEST["body"]) == '') {
logger('facebook: empty body '.$item->id.' '.print_r($item, true));