diff --git a/fbsync/object/Facebook.php b/fbsync/object/Facebook.php index 8e7598b3..10eef0d2 100644 --- a/fbsync/object/Facebook.php +++ b/fbsync/object/Facebook.php @@ -1,6 +1,7 @@ created_time)); + $postarray['edited'] = datetime_convert('UTC','UTC',date("c", $post->updated_time)); + $postarray['uri'] = "fb::". $post->id; $postarray['thr-parent'] = $postarray['uri']; $postarray['parent-uri'] = $postarray['uri']; //No permalink in new api. Can use one of the action links, they seem to be all the same. //Another option is spliting the id AAA_BBB where AAA is the id of the person, and BBB is the ID of the post. final url would be facebook.com/AAA/post/BBB + //TODO: Remove actions if not in use $ids = split("_", $post->id); $postarray['plink'] = 'https://www.facebook.com/' . $ids[0] . '/posts/' . $ids[1]; + $postarray['author-name'] = $post->from->name; // $contacts[$post->actor_id]->name; + $postarray['author-link'] = 'https://www.facebook.com/' . $post->from->id; //$contacts[$post->actor_id]->url; + + //TODO: Pic not included in graph + //$postarray['author-avatar'] = $contacts[$post->actor_id]->pic_square; + + //TODO: Source not in in graph api. What was this before? Seemed like it was the same as the author with FQL + //$postarray['owner-name'] = $contacts[$post->source_id]->name; + //$postarray['owner-link'] = $contacts[$post->source_id]->url; + //$postarray['owner-avatar'] = $contacts[$post->source_id]->pic_square; + + //TODO: Parent Post Code + + //TODO: Set $postarray['contact-id'] = $contact_id; Should either be the actor_id or the source_id (not in graph?) + + //TODO: Body does not seem to be used in graph or fql any more. What is this value supposed to be? + $postarray["body"] = ""; + + //TODO: Deal with attachments + //Kind of a big deal. + + $postarray['app'] = ($post->application->name == "" ? "Facebook" : $post->application->name); + + if(isset($post->privacy) && $post->privacy->value !== '') { + $postarray['private'] = 1; + $postarray['allow_cid'] = '<' . $uid . '>'; + } + + $item = item_store($postarray); + logger('fbsync_createpost: User ' . $uid . ' posted feed item '.$item, LOGGER_DEBUG); + return $postarray; - } - } ?> \ No newline at end of file diff --git a/fbsync/tests/fbsync_test.php b/fbsync/tests/fbsync_test.php index e81c6372..7c9fdc1b 100644 --- a/fbsync/tests/fbsync_test.php +++ b/fbsync/tests/fbsync_test.php @@ -29,7 +29,9 @@ $myFBSync = new Facebook_Graph21($uid); if ($myFBSync->uid != 1) die("class did not load"); if ($myFBSync->access_token == '') die("failed to load access_token"); +//Test FetchContact +//Test CreatePost $posts = json_decode(file_get_contents("./addon/fbsync/tests/graph2.1.txt")); $post = $myFBSync->CreatePost($a,0,0,0,$posts->data[0],0); @@ -42,11 +44,13 @@ if ($post['plink'] != "https://www.facebook.com/109524391244/posts/1015248318782 //test creating the same post again +echo "All done\n"; + /* https://developers.facebook.com/tools/explorer SELECT action_links, actor_id, app_data, app_id, attachment, attribution, comment_info, created_time, filter_key, like_info, message, message_tags, parent_post_id, permalink, place, post_id, privacy, share_count, share_info, source_id, subscribed, tagged_ids, type, updated_time, with_tags FROM stream where filter_key ='nf' ORDER BY updated_time DESC LIMIT 5 - +//Todo:Actions can probably be removed me/home?fields=actions&since=992438&updated_time=0&filter=nf&limit=1 me/home?fields=actions,link,id,created_time,application,attachments,updated_time,object_id,with_tags,comments{can_comment,comment_count},likes,message,message_tags,description,parent_id,place,privacy,shares&limit=1 https://developers.facebook.com/docs/graph-api/reference/v2.1/test-user