Overview
You can streamline your workflow and automate your social publishing with Naytev's Content API, included in select Enterprise Licenses.
Integrating your CMS with Naytev's API allows you to complete two primary actions:
Instantly add content to your social handle's content library.
Automatically schedule a post once you publish your content on your CMS.
In the tutorial below, we will outline the process of automatically scheduling a post through Naytev after publishing content within your CMS.
Step 1: Obtain an API Token
Before we begin, you'll need an Access Token. The Naytev API is secured using API access tokens for your organization. To obtain an Access Token for your organization, log in to your Naytev account. On the left side, click Account > API > Create Your First API Token. Clicking this will create and display your API token. Learn more here.
Step 2: Find Your Team and Social Handles
Now that you have your access token, you will need to identify the Naytev teams and the authorized social handles you plan to use with the API. Your organization may contain multiple teams, and each team may have many social handles.
You can obtain list of your organization's teams via the API. Here's an example using the CURL terminal utility:
curl --header "X-Auth-Token: cc868f8a334897d19068832715d6d899353f6f0ea76ab4a49e47aaad633b001e" https://api.naytev.com/v1/team
[{
"id":1,
"name":"Test Team 1"
},
{
"id":2,
"name":"Test Team 2"
}]
Now that you have your teams and their respective ID's, you can obtain the social handles associated with them. Here's an example CURL request to obtain the social handle info for the first team:
curl --header "X-Auth-Token: cc868f8a334897d19068832715d6d899353f6f0ea76ab4a49e47aaad633b001e" https://api.naytev.com/v1/team/1/socialHandle
[
{
"id": 1,
"name": "Naytev",
"network": "FacebookPage",
"networkURL": "https://www.facebook.com/1438235733064962",
"isSchedulerActive": true,
"timezone": "US/Pacific"
}
]
You'll notice the ID field of the Social Handle Object. That is what you will use to schedule posts and add content. This ID is unique will never change, even if you delete and add the page again. You can save this ID in your database or keep it in your constants file.
This ID is distinct from the IDs that Facebook, Twitter or Pinterest may use to refer to the social handle on their network.
Create a Post
Now that you have your Facebook Page and its ID, you can create a post. To create a social post, you will use the /post endpoint and will specify the content as part of the request.
As an example, let's share an article from the Naytev Blog: What Networks Does BuzzFeed Use. In the next article, we'll cover how to post using different scheduling options. For this example we'll schedule the post to be shared in the next 7 days at an optimal time identified by Naytev (using Naytev's Post Intelligently feature).
curl --header "X-Auth-Token: cc868f8a334897d19068832715d6d899353f6f0ea76ab4a49e47aaad633b001e" --header "Content-Type: application/json" https://api.naytev.com/v1/socialHandle/1/post -XPOST -d '{
"type": "FacebookLinkPost",
"message": "80% of BuzzFeed distribution is outside their website",
"link": "http://blog.naytev.com/what-networks-does-buzzfeed-use/",
"options": {
"type": "PostOptimized"
},
"content": {
"type": "LinkContent",
"url": "http://blog.naytev.com/what-networks-does-buzzfeed-use/"
}
}'
Here's the response from Naytev's API:
{
"type": "FacebookLinkPost",
"headline": "What Networks Does BuzzFeed Actually Use?",
"description": "",
"contentID": 1,
"options": {
"type": "PostOptimized",
"onHold": false
},
"id": 1,
"link": "http://blog.naytev.com/what-networks-does-buzzfeed-use/",
"message": "80% of BuzzFeed distribution is outside their website",
"imageURL": "https://naytev-dark.s3.amazonaws.com/uploads/spark/image_stub/38552"
}
With this API request, you created an intelligently scheduled post. You will now see the post in your teams Naytev dashboard in the Post Schedule view.
It's that easy!