- Basic Information Terminology, getting started and setting up your account. Recommended for new customers.
- Make your website social Step-by-step tutorials and information on how to integrate our plugins and services to your site.
- REST API Reference JSON/REST API for advanced social network integration. Must-read for developers.
Social Sharing API \ Publish a message to one or more social networks
Send a POST request to this resource to publish a new sharing message on behalf of a user.
| Social Sharing API Resources/URI | GET | POST | PUT | DELETE |
Sharing Messages /sharing/messages.<format> |
List published messages | Publish a new message | – | – |
Sharing Message /sharing/messages/<sharing_message_token>.<format> |
Get message details | Re-Publish a message | – | Delete a message |
Workflow
1. Request: the code to send to the API
Send a POST request to the resource /sharing/messages.<format>
and include the structure below as POST data to publish a new message to
one or more social networks (code example).
The message representation ultimately depends on the provider. For Twitter for example the message will be published as a new Tweet and for Facebook & LinkedIn as a post on the user's wall. You can publish a message on multiple social networks simultaneously, the API takes care of dispatching the message accordingly.
- Publish a new message on behalf of a user to multiple social network simultaneously
- Publish a new message on behalf of a user to a given social network identity
1.1. Publish a new message on behalf of a user to multiple social network simultaneously
- What is a
<user_token>?- A <user_token> uniquely identifies one of your users;
- A <user_token> will be returned after a user has logged in to your Site with our Social Login Plugin;
- The <user_token> for each of your users is included in the user list;
- Include the <user_token> in the structure send to the API to specify on behalf of which user you want to post the message.
{
"request": {
"sharing_message": {
"publish_for_user": {
"user_token": "<user_token>",
"providers": [
"facebook",
"twitter",
"linkedin"
]
},
"parts": {
"text": {
"body": "Message Body"
},
"picture": {
"url": "http://www.example.com/my_picture.png"
},
"video": {
"url": "http://www.example.com/my_video.mov"
},
"link": {
"url": "http://www.example.com/url1.html",
"name": "Example Site",
"caption": "Text Below Link",
"description": "Link description, can contain an url http://www.example.com/url2.html"
}
"flags": {
"enable_tracking": "1"
}
}
}
}
}
1.2. Publish a new message on behalf of a user to a given social network identity
- What is a
<identity_token>?- A <identity_token> uniquely identifies the social network profile one of your users;
- A <identity_token> will be returned after a user has logged in to your Site with our Social Login Plugin;
- A user can have multiple identites, each identity belongs to one sole user.
{
"request": {
"sharing_message": {
"publish_for_identity": {
"identity_token": "<identity_token>"
},
"parts": {
"text": {
"body": "Message Body"
},
"picture": {
"url": "http://www.example.com/my_picture.png"
},
"video": {
"url": "http://www.example.com/my_video.mov"
},
"link": {
"url": "http://www.example.com/url1.html",
"name": "Example Site",
"caption": "Text Below Link",
"description": "Link description, can contain an url http://www.example.com/url2.html"
}
"flags": {
"enable_tracking": "1"
}
}
}
}
}
2. Result: the code returned by the API
You can publish a message to multiple providers simultaneously and you will therefore always obtain a publications resultset
that contains different result codes - one response for each of the chosen providers.
If the overall response status is 207,
you should examine the status section of each publications sub-result for further information about the success or failure of the method execution.
- The API may return one of the following status codes:
- 200 : The message has been published successfully to each of the chosen providers;
- 207 : The message has been published successfully to some but not to all of the chosen providers;
- 4xx : The message has been published to none of the chosen providers
sharing_message_token
The obtained sharing_message_token uniquely identifies the published message. Use it to
obtain the message details,
to publish the message once again or to
delete it.
tracked_shorturls
If you have enabled link tracking, the links contained in your message will be shortened. If a user clicks
on a shortened url, the click is counted and the user is instantly redirected to the original url. Use
the shorturl_token to retrieve the details of an url.
Result Example
{
"response": {
"request": {
"date": "Tue, 20 Dec 2011 19:11:42 +0100",
"resource": "/sharing/messages.json",
"status": {
"flag": "multistatus",
"code": 207,
"info": "Your request has partially been processed, multiple results and response codes available"
}
},
"result": {
"data": {
"sharing_message": {
"sharing_message_token": "a1ddb4d0-9263-4872-b0e7-18a5565bf78b",
"date_creation": "Tue, 20 Dec 2011 19:11:41 +0100",
"publications": {
"count": 2,
"entries ": [
{
"status": {
"flag": "success",
"code": 200,
"message": "Message published successfully to identity"
},
"provider": "facebook",
"user_token": "c1d82726-e81d-4e89-82af-fed19df8f64e",
"identity_token": "32eb78f4-f82e-4833-8a7b-fa0348c6ff5d",
"date_publication": "Tue, 20 Dec 2011 19:11:41 +0100",
"shorturls": {
"count": 1,
"entries": [
{
"shorturl_token": "6bTth",
"original_url": "http://www.oneall.com/",
"short_url": "http://oal.lu/6bTth",
"date_creation": "Tue, 20 Dec 2011 19:11:41 +0100",
"num_referrals":0
}
]
}
},
{
"status": {
"flag": "error_user_has_no_identity_for_this_provider",
"code": 404,
"message": "The API could not publish the message: this user has no identity for Twitter"
},
"provider": "twitter",
"user_token": "c1d82726-e81d-4e89-82af-fed19df8f64e"
}
]
}
}
}
}
}
}
Code Example
Publish a new sharing message on behalf of a user
<?php
//NOTE: Replace the #placeholders# with your own values
//The user_token
$user_token = '#<user_token>#';
//Your Site API Credentials
$site_subdomain = '#site subdomain#';
$site_public_key = '#site public key/username#';
$site_private_key = '#site private key/password#';
//The resource to send the request to
$api_resource_uri = 'https://'.$site_subdomain . ".api.oneall.com/sharing/messages.json";
//The POST data to be included
$post_data = array(
'request' => array(
'sharing_message' => array(
'parts' => array(
'text' => array(
'body' => 'oneall simplifies the integration of social networks for Web 2.0 and SaaS companies'
),
'picture' => array(
'url' => 'http://oneallcdn.com/img/heading/slides/provider_grid.png'
),
'link' => array(
'url' => 'http://www.oneall.com/',
'name' => 'oneall.com',
'caption' => 'Social Media Integration',
'description' => 'Easily integrate social services like Facebook, Twitter, LinkedIn and Foursquare with your already-existing website.'
),
'flags' => array(
'enable_tracking' => 1
)
),
'publish_for_user' => array(
'user_token' => $user_token,
'providers' => array('facebook', 'twitter', 'linkedin')
)
)
)
);
//Setup CURL
$curl = curl_init ();
curl_setopt_array ($curl, array (
CURLOPT_URL => $api_resource_uri,
CURLOPT_USERPWD => $site_public_key . ":" . $site_private_key,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CUSTOMREQUEST => "POST", // <== Send a POST request
CURLOPT_POSTFIELDS => json_encode($post_data) // <== Include the JSON POST data
));
//Send Request
$data = curl_exec ($curl);
//Error
if ($data === false)
{
echo 'Curl Error: ' . curl_error ($curl);
}
//Success
else
{
echo 'Received Result: ' . $data;
}
//Close connection
curl_close ($curl);
?>