PHP code example of stackla / stackla-php-sdk

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

    

stackla / stackla-php-sdk example snippets


#!php

// Stackla stack name
$stack = "foo";

// Stackla Credentials details
$host = "https://api.stackla.com/api/";
$accessToken = "1234567890"; // OAuth2 access_token
$credentials = new \Stackla\Core\Credentials($host, $accessToken, $stack);

// Stackla API configs
$stack = new \Stackla\Api\Stack($credentials, $host, $stack);
#!php

$stack = "foo";
$host  = "https://api.stackla.com/api/";
$client_id = '1234567890';
$client_secret = '0987654321';
$callback = 'https://test.com/callback.php';

$credentials = new Stackla\Core\Credentials($host, null, $stack);
$access_uri = $credentials->getAccessUri($client_id, $client_secret, $callback);

printf('<a href="%s">Generate Access Token</a>', $access_uri);
#!php

$stack = "foo";
$host  = "https://api.stackla.com/api/";
$client_id = '1234567890';
$client_secret = '0987654321';
$callback = 'https://test.com/callback.php';

$access_code = $_GET['code'];

$credentials = new Stackla\Core\Credentials($host, null, $stack);
$response = $credentials->generateToken($client_id, $client_secret, $access_code, $callback);

if ($response === false) {
    echo "Failed to create the access token.\n";
} else {
    echo "Your access token is '{$credentials->token}'\n";
}


#!php

// Stackla stack name
$stack = "foo";

// Stackla Credentials details
$host = "https://api.stackla.com/api/";
$apiKey = "1234567890"; // Stackla api key
$credentials = new \Stackla\Core\Credentials($host, $apiKey, $stack, \Stackla\Core\Credentials::TYPE_APIKEY);

// Stackla API configs
$stack = new \Stackla\Api\Stack($credentials, $host, $stack);
array
$id
#!php
// Create new instance of term
$term = $stack->instance('term');
// get 25 terms from RESTful API
$term->get();

// Work with each term
foreach ($term as $iterm) {
    echo $iterm->id . " - " . $iterm->name . " - " . " - " . $iterm->network;
}