first post went in

This commit is contained in:
Ben Liyanage 2014-10-08 16:24:48 -04:00
parent 24a1cb695f
commit dfffacb9c8
3 changed files with 44 additions and 6 deletions

View file

@ -1,6 +1,7 @@
<?php
require_once('include/items.php');
class Facebook
class Facebook
{
function CreatePost($a, $uid, $self, $contacts, $applications, $post, $create_user)
{

View file

@ -2,7 +2,7 @@
require_once("./addon/fbsync/object/Facebook.php");
Class Facebook_Graph21 //implements Facebook
Class Facebook_Graph21 extends Facebook
{
public $access_token;// = "test";
public $uid;
@ -34,20 +34,53 @@ Class Facebook_Graph21 //implements Facebook
$postarray['verb'] = ACTIVITY_POST;
$postarray['object-type'] = ACTIVITY_OBJ_NOTE; // default value - is maybe changed later when media is attached
$postarray['network'] = dbesc(NETWORK_FACEBOOK);
$postarray['created'] = datetime_convert('UTC','UTC',date("c", $post->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;
}
}
?>

View file

@ -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