Buffer API : Automatically Post Updates on Buffer
PHP Buffer API: We are using buffer api to automatically post update on Buffer.
Buffer is a social networking app that provide you a platform to manage your multiple social network accounts on a single website.
In this tutorial we are using PHP to use buffer api to automatically post updates on Buffer.
How I got this Idea to write about Buffer API?
I have recently created a micro niche website
Whatsapp Video Download, which let you download whatsapp videos on a single platform.
There is hell lot of Videos which I can’t manage to publish each and every video on its(
Whatsapp Video Download) Social pages.
So I created a buffer account and used Buffer api to manage all this and then I thought it might also help you.
Get your Buffer Access Token
Your first step toward using buffer api is to register a Buffer app.Follow the below steps to register your buffer app to get access token:
Step #1 : Login to your Buffer Account.
If you don’t have a buffer account then create a new account and then login.
Step #2 : Go to Buffer Developers Page.
Step #3 : Create New Buffer App for your application.
Step #4 : Fill Your Buffer App details.
Step #5 : Copy your new Buffer App Access Token.
You will get an access token after registering your new buffer app successfully.
Step #6: Download our Script and edit the
Edit the following line in
$buffer = new Buffer('YOUR ACCESS TOKEN');
Replace YOUR ACCESS TOKEN with your new Buffer app Access Token.
Create New Update on Buffer
Now, it’s time to create a new update on buffer to post on our social networks.
Create a new array that contains post data with the profile ids(Buffer profiles).
$data = array('profile_ids'=>array());
Now you have to add your buffer profile ids to the array
$data['profile_ids'] = 'YOUR BUFFER PROFILE ID'; $data['profile_ids'] = 'Your ANOTHER BUFFER PROFILE ID'; //You can add even more buffer ids
To get your buffer id click on your social accounts from left sidebar and then copy your buffer id from your Browser URL bar.
Now add the text you want to update in your post.
$data['text'] = "Add your Text here.";
Let’s say you have to update your post with a link.
How will you do that?
You will add an associative array of media with the data array.
Let’s say you have to add url with custom title and description with your update.You can add an associative array containing the url,title and description to
$data['media'] = array( 'url'=>'http://whatsappvideodownload.in', 'title'=>"Your URL/Custom Title", 'description'=>"Your URL/Custom Description" );
Now let’s say you post images with your update, then add as associative array to
$data['media'] containing photo and thumbnail.
$data['media'] = array( 'photo'=>'Your PHOTO url', 'thumbnail'=>'Yout Thumbnail Url' );
You can get a complete guide of when to use picture,photo and thumbnail on buffer developers page.
If you want to publish your post instantly then add the following code:
$data['now'] = true;
If you want to shorten your link then add the following code:
$data['shorten'] = true;
Now you have the data to post on buffer,use the following code to send data to buffer.
Below is the full code of the
share.php file of this php buffer api script.
<?php // You need to create an app at http://bufferapp.com/developers/apps/create before you can go any further! // Having problems? Try uncomment the line below //error_reporting(E_ALL); require_once 'buffer.class.php'; // This was generated when you created your app $buffer = new Buffer('YOUR ACCESS TOKEN'); $data = array('profile_ids' => array()); // Your profile ids which can be found on your dashboard (http://bufferapp.com/dashboard) $data['profile_ids'] = 'YOUR BUFFER PROFILE ID'; $data['profile_ids'] = 'Your ANOTHER BUFFER PROFILE ID'; // The text for your update $data['text'] = "Add your Text here."; //Uncomment the below lines to update your post with link //$data['media'] = array( // 'url'=>'http://mycodingtricks.com', // 'title'=>"Your URL/Custom Title", // 'description'=>"Your URL/Custom Description" //); //Uncomment the below line to update your post with photo //$data['media'] = array('photo' => $thumb, 'thumbnail' => $thumb); //Uncomment the below link to publish your update instantly //$data['now']=true; //Uncomment the below line to shoten your link //$data['shorten']=true; $ret = $buffer->post('updates/create', $data); // Still having problems figuring out why it's not working? Try uncommenting the line below to see what the API is returning //var_dump($ret);
Woo hoo!We are done now. When you run this php script, you update will be shown on your buffer dashboard.
Hope you will like it.