mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-17 05:48:49 +00:00
got some initial fields set
This commit is contained in:
parent
0996ab115a
commit
b3d813b7aa
3 changed files with 41 additions and 47 deletions
|
@ -1,41 +1,53 @@
|
|||
<?php
|
||||
require_once("Facebook.php");
|
||||
|
||||
Class Facebook_Graph21 implements Facebook
|
||||
require_once("./addon/fbsync/object/Facebook.php");
|
||||
|
||||
Class Facebook_Graph21 //implements Facebook
|
||||
{
|
||||
public $access_token;
|
||||
public $access_token;// = "test";
|
||||
public $uid;
|
||||
|
||||
function Facebook_Graph21()
|
||||
function __construct($uid)
|
||||
{
|
||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||
$this->uid = $uid;
|
||||
$this->access_token = get_pconfig($uid,'facebook','access_token');
|
||||
}
|
||||
|
||||
function CreatePost($a, $uid, $self, $contacts, $applications, $post, $create_user)
|
||||
function CreatePost($a, $self, $contacts, $applications, $post, $create_user)
|
||||
{
|
||||
//Sanitize Inputs
|
||||
|
||||
//Check if post exists
|
||||
//This is legacy--shouldn't we check if the various parts of the post was updated?
|
||||
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
|
||||
intval($uid),
|
||||
dbesc('fb::'.$post->post_id)
|
||||
intval($this->uid),
|
||||
dbesc('fb::'.$post->id)
|
||||
);
|
||||
if(count($r))
|
||||
return;
|
||||
|
||||
$postarray = array();
|
||||
$postarray['gravity'] = 0;
|
||||
$postarray['uid'] = $uid;
|
||||
$postarray['uid'] = $this->uid;
|
||||
$postarray['wall'] = 0;
|
||||
|
||||
$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['uri'] = "fb::".$post->post_id;
|
||||
$postarray['uri'] = "fb::". $post->id;
|
||||
$postarray['thr-parent'] = $postarray['uri'];
|
||||
$postarray['parent-uri'] = $postarray['uri'];
|
||||
$postarray['plink'] = $post->permalink;
|
||||
|
||||
//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
|
||||
$ids = split("_", $post->id);
|
||||
$postarray['plink'] = 'https://www.facebook.com/' . $ids[0] . '/posts/' . $ids[1];
|
||||
|
||||
return $postarray;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -15,6 +15,7 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
|
|||
//var_dump($data);
|
||||
|
||||
//Test Data Processing
|
||||
$uid = 1;
|
||||
|
||||
// Test Base Class
|
||||
require_once("./addon/fbsync/object/Facebook.php");
|
||||
|
@ -22,10 +23,23 @@ $myFBSync = new Facebook();
|
|||
|
||||
// Test graph 2.1 class
|
||||
require_once("./addon/fbsync/object/Facebook_Graph21.php");
|
||||
$myFBSync = new Facebook_Graph21();
|
||||
$uid = 1;
|
||||
$post = json_decode(readfile("./addon/fbsync/tests/graph2.1.txt"));
|
||||
$myFBSync->CreatePost($a,$uid,0,0,0,$post,0);
|
||||
$myFBSync = new Facebook_Graph21($uid);
|
||||
|
||||
//verify class loaded correctly
|
||||
if ($myFBSync->uid != 1) die("class did not load");
|
||||
if ($myFBSync->access_token == '') die("failed to load access_token");
|
||||
|
||||
|
||||
$posts = json_decode(file_get_contents("./addon/fbsync/tests/graph2.1.txt"));
|
||||
|
||||
$post = $myFBSync->CreatePost($a,0,0,0,$posts->data[0],0);
|
||||
|
||||
//verify data
|
||||
if ($post['uri'] != "fb::109524391244_10152483187826245") die("uri does not match");
|
||||
if ($post['plink'] != "https://www.facebook.com/109524391244/posts/10152483187826245") die("plink does not match");
|
||||
|
||||
//var_dump($posts->data[0]);
|
||||
//test creating the same post again
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -49,38 +49,6 @@
|
|||
},
|
||||
"created_time": "2014-10-08T16:01:20+0000",
|
||||
"updated_time": "2014-10-08T16:01:20+0000"
|
||||
},
|
||||
{
|
||||
"id": "146218052067513_801079643248014",
|
||||
"from": {
|
||||
"category": "Local business",
|
||||
"category_list": [
|
||||
{
|
||||
"id": "2500",
|
||||
"name": "Local Business"
|
||||
}
|
||||
],
|
||||
"name": "The Loading Dock, Inc.",
|
||||
"id": "146218052067513"
|
||||
},
|
||||
"message": "Blow In Insulation\n\n$2/ bag\n\nEach bag covers about 10 sf (at 6\" thickness)\n\nInsulation is used but very, very clean.\n\nRoughly 860 sf is available.",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Comment",
|
||||
"link": "https://www.facebook.com/146218052067513/posts/801079643248014"
|
||||
},
|
||||
{
|
||||
"name": "Like",
|
||||
"link": "https://www.facebook.com/146218052067513/posts/801079643248014"
|
||||
}
|
||||
],
|
||||
"privacy": {
|
||||
"value": ""
|
||||
},
|
||||
"type": "status",
|
||||
"status_type": "mobile_status_update",
|
||||
"created_time": "2014-10-08T15:56:47+0000",
|
||||
"updated_time": "2014-10-08T15:56:47+0000"
|
||||
}
|
||||
],
|
||||
"paging": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue