Post updates to Buffer

buffer

Buffer is successful media management tool . If you want to integrate buffer into your website ,this tutorial help you .Buffer is also perfect tool for scheduling twitter and Facebook updates .Buffer API has it’s own very easy and clean documentation .

You can use a buffer library available on github https://github.com/thewebguy/bufferapp-php .Well buffer doesn’t have it’s own library .It uses OAuth 2.0 authentication .

Let’s get started from creating app on https://buffer.com/developers/apps/create .Submit all details there like name, description and some others . Don’t forget to mention there callback url .It allow other users to authenticate themselves.

After successful app registered, you will get client id and client secret and a token . Note down this ,it will require in code.

Now in include the class then create new instance pass in your client id ,secret and callback url.

session_start();
require('buffer.php');

$client_id = 'your_id';
$client_secret = 'your_secret';

$buffer = new BufferApp($client_id, $client_secret, null);

note: above in my case ,i don’t require to put callback url, so i left null.

If you searching for a good Web Development IT Training in Delhi/NCR , contact us .We provide real time project based practical training .
.

Class will store the token in session .Find below hard coded token .

function retrieve_access_token() {
    $this->access_token = 'token';//$_SESSION['oauth']['buffer']['access_token'];

    if ($this->access_token) {
        $this->ok = true;
    }
}

Setting profile’s id as shown below

$profiles = $buffer->go('/profiles');
//print_r($profiles);

Now , Loop over the Id’s and post to Buffer, pass an array to updates/create the only part the array that is required the profile_ids the rest are optional

foreach($profiles as $profile){
    $buffer->go('/updates/create', array(
        'text' => 'My website heading',
        'media[title]'=>  'My website heading ',
        'media[link]'=>  'http://yourwebdomain.com',
        'media[description]'=>  'Here will be sample description!',
        'media[picture]'=>  'http://yourwebdomain.com/images/abc.png',
        'media[thumbnail]'=>  'http://yourwebdomain.com/images/abc.png',
        'profile_ids[]' => $profile
    ));
}

 

it updates to your schedules on Buffer .
Find below complete code in one place .

 session_start();
require('buffer.php');

$client_id = 'your_id';
$client_secret = 'your_secret';

$buffer = new BufferApp($client_id, $client_secret, null);

 $profiles = array(
    '561aa0563v24244c321316b1', 
    '561aa056563bb32c321316b1',
);

foreach($profiles as $profile){
    $buffer->go('/updates/create', array(
        'text' => 'My website heading',
        'media[title]'=>  'My website heading ',
        'media[link]'=>  'http://yourwebdomain.com',
        'media[description]'=>  'Here will be sample description!',
        'media[picture]'=>  'http://yourwebdomain.com/images/abc.png',
        'media[thumbnail]'=>  'http://yourwebdomain.com/images/abc.png',
        'profile_ids[]' => $profile
    ));
}
If you like this tutorial share this on facebook ,twitter from right side of this page . Also remeber us fior Advance IT course in Delhi ,contact us .We provide real time project based practical training .
.

Online Web Development Training,Video Tutorials