Installation
Node.js
Install from npm
npm install soclall-api --save
// Register app id and secret key
var SocialAll = require('soclall-api'), socialall = new SoclAll('app_id', 'secret_key');
Authentication
Let user login and authenticate with your application.
// Get login url
var login_url = socialall.getLoginUrl('network', 'callback_url');
// Redirect user to login url
res.redirect(login_url);
API
/user
This endpoint retrieves user information.
// An user object returns in callback function
socialall.getUser('token', function(err, user){});
The result
returns user
JSON object structured like this:
{
// general
"id": 2,
"username": "Boy",
"email": "boy@socialall.dev",
// name
"full_name": "Boy Nguyen", // full name || first name + lastname
...
}
/friends
This endpoint retrieves user's friends.
// An array of user returns in callback function
socialall.getFriends('token', function(err, friends){});
The result
returns an array of user
object like this:
[
{
"id": 2,
"username": "Boy",
"email": "boy@socialall.dev",
...
},
{
"id": 3,
"username": "Girl",
"email": "girl@socialall.dev",
...
}
]
/message
This endpoint will send message
to user's friends.
// Send a message to friends
socialall.sendMessage('token', 'message', friend_ids, ['title',] function(err){});
/publish
This endpoint will publish a message to user's wall/timeline/stream.
// Publish a message to wall/timeline/stream
socialall.publish('token', 'message', function(err){});
The result
returns a JSON object structured like this:
{
"link": "https://www.facebook.com/.../posts/..."
}