mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-17 05:48:49 +00:00
initial dev
added some mach data for unit testing. Also added some base classes for structuring post creation using different versions of the api
This commit is contained in:
parent
07e2c01689
commit
0996ab115a
7 changed files with 276 additions and 3 deletions
|
@ -213,7 +213,7 @@ function fbsync_expire($a,$b) {
|
|||
}
|
||||
|
||||
function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
|
||||
|
||||
//Sanitize Inputs
|
||||
$post->actor_id = number_format($post->actor_id, 0, '', '');
|
||||
$post->source_id = number_format($post->source_id, 0, '', '');
|
||||
$post->app_id = number_format($post->app_id, 0, '', '');
|
||||
|
|
10
fbsync/object/Facebook.php
Normal file
10
fbsync/object/Facebook.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
class Facebook
|
||||
{
|
||||
function CreatePost($a, $uid, $self, $contacts, $applications, $post, $create_user)
|
||||
{
|
||||
throw new Exception("CreatePost Not Implemented");
|
||||
}
|
||||
}
|
||||
?>
|
41
fbsync/object/Facebook_Graph21.php
Normal file
41
fbsync/object/Facebook_Graph21.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
require_once("Facebook.php");
|
||||
|
||||
Class Facebook_Graph21 implements Facebook
|
||||
{
|
||||
public $access_token;
|
||||
|
||||
function Facebook_Graph21()
|
||||
{
|
||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||
}
|
||||
|
||||
function CreatePost($a, $uid, $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)
|
||||
);
|
||||
if(count($r))
|
||||
return;
|
||||
|
||||
$postarray = array();
|
||||
$postarray['gravity'] = 0;
|
||||
$postarray['uid'] = $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['thr-parent'] = $postarray['uri'];
|
||||
$postarray['parent-uri'] = $postarray['uri'];
|
||||
$postarray['plink'] = $post->permalink;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -9,9 +9,24 @@ $d = datetime_convert();
|
|||
global $db;
|
||||
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
|
||||
|
||||
$data = fbsync_fetchfeed($a, 1);
|
||||
|
||||
var_dump($data);
|
||||
//Test Data Retrieval
|
||||
//$data = fbsync_fetchfeed($a, 1);
|
||||
//var_dump($data);
|
||||
|
||||
//Test Data Processing
|
||||
|
||||
// Test Base Class
|
||||
require_once("./addon/fbsync/object/Facebook.php");
|
||||
$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);
|
||||
|
||||
|
||||
/*
|
||||
https://developers.facebook.com/tools/explorer
|
||||
|
|
64
fbsync/tests/fql.txt
Normal file
64
fbsync/tests/fql.txt
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"action_links": null,
|
||||
"actor_id": "109524391244",
|
||||
"app_data": [
|
||||
],
|
||||
"app_id": "2309869772",
|
||||
"attachment": {
|
||||
"media": [
|
||||
{
|
||||
"href": "http://www.theverge.com/2014/10/8/6946033/google-put-street-view-camera-on-camels-back-to-tour-desert",
|
||||
"alt": "",
|
||||
"type": "link",
|
||||
"src": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQC6sIH1Zb6kwIlg&w=158&h=158&url=http%3A%2F%2Fcdn1.vox-cdn.com%2Fuploads%2Fchorus_image%2Fimage%2F41261020%2FScreen_Shot_2014-10-08_at_10.44.15_AM.0.0_cinema_1200.0.png"
|
||||
}
|
||||
],
|
||||
"name": "Google put its Street View camera on a camel's back to tour the Arabian desert",
|
||||
"href": "http://www.theverge.com/2014/10/8/6946033/google-put-street-view-camera-on-camels-back-to-tour-desert",
|
||||
"caption": "www.theverge.com",
|
||||
"description": "Google's Street View cameras have been carried around on cars, boats, people, and now camels. The company recently set out to capture 360-degree imagery of the Arabian desert, and to \"minimize\"...",
|
||||
"properties": [
|
||||
],
|
||||
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif"
|
||||
},
|
||||
"attribution": null,
|
||||
"comment_info": {
|
||||
"can_comment": true,
|
||||
"comment_count": 0,
|
||||
"comment_order": "chronological"
|
||||
},
|
||||
"created_time": 1412784080,
|
||||
"filter_key": "nf",
|
||||
"like_info": {
|
||||
"can_like": true,
|
||||
"like_count": 0,
|
||||
"user_likes": false
|
||||
},
|
||||
"message": "",
|
||||
"message_tags": [
|
||||
],
|
||||
"parent_post_id": null,
|
||||
"permalink": "https://www.facebook.com/baltimorenode/posts/10152483187826245",
|
||||
"place": null,
|
||||
"post_id": "109524391244_10152483187826245",
|
||||
"privacy": {
|
||||
"value": ""
|
||||
},
|
||||
"share_count": 0,
|
||||
"share_info": {
|
||||
"can_share": true,
|
||||
"share_count": 0
|
||||
},
|
||||
"source_id": "109524391244",
|
||||
"subscribed": false,
|
||||
"tagged_ids": [
|
||||
],
|
||||
"type": 80,
|
||||
"updated_time": 1412784080,
|
||||
"with_tags": [
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
90
fbsync/tests/graph2.1-no-filter.txt
Normal file
90
fbsync/tests/graph2.1-no-filter.txt
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "109524391244_10152483187826245",
|
||||
"from": {
|
||||
"category": "Non-profit organization",
|
||||
"category_list": [
|
||||
{
|
||||
"id": "133436743388217",
|
||||
"name": "Arts & Entertainment"
|
||||
},
|
||||
{
|
||||
"id": "139823692748565",
|
||||
"name": "Computers & Electronics"
|
||||
},
|
||||
{
|
||||
"id": "292231357479999",
|
||||
"name": "Robotics"
|
||||
}
|
||||
],
|
||||
"name": "Baltimore Node",
|
||||
"id": "109524391244"
|
||||
},
|
||||
"story": "Baltimore Node shared a link.",
|
||||
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQC6sIH1Zb6kwIlg&w=158&h=158&url=http%3A%2F%2Fcdn1.vox-cdn.com%2Fuploads%2Fchorus_image%2Fimage%2F41261020%2FScreen_Shot_2014-10-08_at_10.44.15_AM.0.0_cinema_1200.0.png",
|
||||
"link": "http://www.theverge.com/2014/10/8/6946033/google-put-street-view-camera-on-camels-back-to-tour-desert",
|
||||
"name": "Google put its Street View camera on a camel's back to tour the Arabian desert",
|
||||
"caption": "www.theverge.com",
|
||||
"description": "Google's Street View cameras have been carried around on cars, boats, people, and now camels. The company recently set out to capture 360-degree imagery of the Arabian desert, and to \"minimize\"...",
|
||||
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Comment",
|
||||
"link": "https://www.facebook.com/109524391244/posts/10152483187826245"
|
||||
},
|
||||
{
|
||||
"name": "Like",
|
||||
"link": "https://www.facebook.com/109524391244/posts/10152483187826245"
|
||||
}
|
||||
],
|
||||
"privacy": {
|
||||
"value": ""
|
||||
},
|
||||
"type": "link",
|
||||
"status_type": "shared_story",
|
||||
"application": {
|
||||
"name": "Links",
|
||||
"id": "2309869772"
|
||||
},
|
||||
"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": {
|
||||
"previous": "https://graph.facebook.com/v2.1/10152271780185899/home?limit=10&since=1412784449",
|
||||
"next": "https://graph.facebook.com/v2.1/10152271780185899/home?limit=10&until=1412780437"
|
||||
}
|
||||
}
|
53
fbsync/tests/graph2.1.txt
Normal file
53
fbsync/tests/graph2.1.txt
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"name": "Comment",
|
||||
"link": "https://www.facebook.com/109524391244/posts/10152483187826245"
|
||||
},
|
||||
{
|
||||
"name": "Like",
|
||||
"link": "https://www.facebook.com/109524391244/posts/10152483187826245"
|
||||
}
|
||||
],
|
||||
"link": "http://www.theverge.com/2014/10/8/6946033/google-put-street-view-camera-on-camels-back-to-tour-desert",
|
||||
"id": "109524391244_10152483187826245",
|
||||
"created_time": "2014-10-08T16:01:20+0000",
|
||||
"application": {
|
||||
"name": "Links",
|
||||
"id": "2309869772"
|
||||
},
|
||||
"updated_time": "2014-10-08T16:01:20+0000",
|
||||
"description": "Google's Street View cameras have been carried around on cars, boats, people, and now camels. The company recently set out to capture 360-degree imagery of the Arabian desert, and to \"minimize\"...",
|
||||
"privacy": {
|
||||
"value": ""
|
||||
},
|
||||
"attachments": {
|
||||
"data": [
|
||||
{
|
||||
"description": "Google's Street View cameras have been carried around on cars, boats, people, and now camels. The company recently set out to capture 360-degree imagery of the Arabian desert, and to \"minimize\"...",
|
||||
"media": {
|
||||
"image": {
|
||||
"height": 674,
|
||||
"src": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQBgDPhjhIZYFbxy&w=720&h=720&url=http%3A%2F%2Fcdn1.vox-cdn.com%2Fuploads%2Fchorus_image%2Fimage%2F41261020%2FScreen_Shot_2014-10-08_at_10.44.15_AM.0.0_cinema_1200.0.png&cfs=1",
|
||||
"width": 674
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"id": "10152483187826245",
|
||||
"url": "http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.theverge.com%2F2014%2F10%2F8%2F6946033%2Fgoogle-put-street-view-camera-on-camels-back-to-tour-desert&h=XAQGWkIO2&s=1&enc=AZNOhgg2O7yFa63a0PeP8UE1EdJLbSArpD1HntdBft53llpu9kK38pKnp5svQCc6B355x1mgDXK3fD6dZfqIm29e"
|
||||
},
|
||||
"title": "Google put its Street View camera on a camel's back to tour the Arabian desert",
|
||||
"type": "share",
|
||||
"url": "http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.theverge.com%2F2014%2F10%2F8%2F6946033%2Fgoogle-put-street-view-camera-on-camels-back-to-tour-desert&h=XAQGWkIO2&s=1&enc=AZNOhgg2O7yFa63a0PeP8UE1EdJLbSArpD1HntdBft53llpu9kK38pKnp5svQCc6B355x1mgDXK3fD6dZfqIm29e"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"paging": {
|
||||
"previous": "https://graph.facebook.com/v2.1/10152271780185899/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&since=1412784080",
|
||||
"next": "https://graph.facebook.com/v2.1/10152271780185899/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&until=1412784079"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue