PHP code example of timacdonald / kumulos

1. Go to this page and download the library: Download timacdonald/kumulos 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/ */

    

timacdonald / kumulos example snippets


use TiMacDonald\Kumulos\Api;

/**
 * Create our api object instance.
 */
$api = new Api($key, $secret);

/**
 * Call an API method on the object, passing in an associative array of values.
 */
$api->createUser([
    'name' => 'Tim MacDonald',
    'twitter' => '@timacdonald87',
    'github' => 'timacdonald',
    'website' => 'timacdonald.me'
]);

/**
 * Check if it failed.
 */
if ($api->failed()) {
    // deal with failure, perhaps with an exception
    throw new Exception($api->response()->message(), $api->response()->statusCode());
}

/**
 * Retrieve the response payload.
 */
$userId = $api->response()->payload();

// Check if it failed
if ($api->failed()) {
    // deal with failure, perhaps with an exception
    throw new Exception($api->response()->normalizedMessage(), $api->response()->normalizedStatusCode());
}

return [
    'kumulos' => [
        'key' => env('KUMULOS_API_KEY'),
        'secret' => env('KUMULOS_API_SECRET')
    ],
    ...

$this->app->bind(\TiMacDonald\Kumulos\Api::class, function ($app) {
    return new \TiMacDonald\Kumulos\Api(
        $app['config']->get('services.kumulos.key'),
        $app['config']->get('services.kumulos.secret')
    );
});



namespace App\Http\Controllers;

use TiMacDonald\Kumulos\Api;

class UserController extends Controller
{
    public function store(Api $api)
    {
        $api->createUser([
            'name' => 'Tim MacDonald',
            'twitter' => '@timacdonald87',
            'github' => 'timacdonald',
            'website' => 'timacdonald.me'
        ]);

        //
    }
}