PHP code example of otar / puffer

1. Go to this page and download the library: Download otar/puffer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

otar / puffer example snippets




use Puffer\Puffer;

$puffer = new Puffer([
    'consumer_key' => 'YOUR_CONSUMER_KEY_HERE',
    'consumer_secret' => 'YOUR_CONSUMER_SECRET_HERE',
    'access_token' => 'YOUR_ACCESS_TOKEN_HERE', // If you have one, or authorization will be ));
    exit;
}

var_dump($puffer->user); // Get user settings



use Puffer\Profiles;

$profiles = new Profiles;

var_dump($profiles->all()); // All profiles

// Also Profiles object can be accessed as an array,
$first_profile = $profiles[0];

// be counted,
$number_of_profiles = count($profiles);

// or even be iterated.
foreach ($profiles AS $profile) {
    $profile->create('Hello World');
}



use Puffer\Profiles;

// Grab first profile and it's pending updates in one line.
$pending = (new Profiles)[0]->pending();



use Puffer\Profile;

$profile = new Profile('YOUR_PROFILE_ID_HERE');
$result = $profile->create('Hello World');

if ((bool) $result->success) {
    echo 'One more update buffered in your queue.';
} else {
    echo 'Something went wrong.';
}

// Or like this:

$result = (new Profile('YOUR_PROFILE_ID_HERE'))->create('Hello World');



use Puffer\Profiles;
use Puffer\Update;

// If you have an update id, then:
$update = new Update('UPDATE_ID_HERE');
$update->delete();

// Or grab first profile and delete first pending update in one line:

$result = (new Profiles)[0]->pending()[0]->destroy();