mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-19 23:07:03 +00:00
first post went in
This commit is contained in:
parent
24a1cb695f
commit
dfffacb9c8
3 changed files with 44 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
require_once('include/items.php');
|
||||||
|
|
||||||
class Facebook
|
class Facebook
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once("./addon/fbsync/object/Facebook.php");
|
require_once("./addon/fbsync/object/Facebook.php");
|
||||||
|
|
||||||
Class Facebook_Graph21 //implements Facebook
|
Class Facebook_Graph21 extends Facebook
|
||||||
{
|
{
|
||||||
public $access_token;// = "test";
|
public $access_token;// = "test";
|
||||||
public $uid;
|
public $uid;
|
||||||
|
@ -35,19 +35,52 @@ Class Facebook_Graph21 //implements Facebook
|
||||||
$postarray['object-type'] = ACTIVITY_OBJ_NOTE; // default value - is maybe changed later when media is attached
|
$postarray['object-type'] = ACTIVITY_OBJ_NOTE; // default value - is maybe changed later when media is attached
|
||||||
$postarray['network'] = dbesc(NETWORK_FACEBOOK);
|
$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['uri'] = "fb::". $post->id;
|
||||||
$postarray['thr-parent'] = $postarray['uri'];
|
$postarray['thr-parent'] = $postarray['uri'];
|
||||||
$postarray['parent-uri'] = $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.
|
//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
|
//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);
|
$ids = split("_", $post->id);
|
||||||
$postarray['plink'] = 'https://www.facebook.com/' . $ids[0] . '/posts/' . $ids[1];
|
$postarray['plink'] = 'https://www.facebook.com/' . $ids[0] . '/posts/' . $ids[1];
|
||||||
|
|
||||||
return $postarray;
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -29,7 +29,9 @@ $myFBSync = new Facebook_Graph21($uid);
|
||||||
if ($myFBSync->uid != 1) die("class did not load");
|
if ($myFBSync->uid != 1) die("class did not load");
|
||||||
if ($myFBSync->access_token == '') die("failed to load access_token");
|
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"));
|
$posts = json_decode(file_get_contents("./addon/fbsync/tests/graph2.1.txt"));
|
||||||
|
|
||||||
$post = $myFBSync->CreatePost($a,0,0,0,$posts->data[0],0);
|
$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
|
//test creating the same post again
|
||||||
|
|
||||||
|
|
||||||
|
echo "All done\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
https://developers.facebook.com/tools/explorer
|
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
|
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&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
|
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
|
https://developers.facebook.com/docs/graph-api/reference/v2.1/test-user
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue