PHP code example of eiyaro / core-php

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

    

eiyaro / core-php example snippets




$base_uri = 'https://api.eiyaro.com';
$accessToken = null;

use EIYARO\API;

$api = new API($base_uri, $accessToken);

echo "== Net Info ==\n";
$netInfo = $api->getNetInfo();
echo json_encode($netInfo) . "\n";
echo "==============\n\n";

echo "== Block Count ==\n";
$blockCount = $api->getBlockCount();
echo "Height: {$blockCount}\n";
echo "=================\n\n";

echo "== Block ==\n";
$block = $api->getBlock($6635);
echo "Block({$blockCount}): {$block->hash}\n";
echo "===========\n\n";

echo "== Transaction ==\n";
try {
    $transaction = $api->getTransaction("fc64be31e56a448879f9984599cafead466ec5b1a985c6ce8e6d45685c55b7d1");
    echo json_encode($transaction, JSON_PRETTY_PRINT) . "\n";
} catch (Exception $e) {
    echo "Error: ". $e->getMessage() ."\n";
}
echo "===========\n\n";

echo "== List Pending Transactions ==\n";
$transactions = $api->getPendingTransactions();
echo json_encode($transactions, JSON_PRETTY_PRINT)."\n";
echo "===========\n\n";

echo "== Get Pending Transaction ==\n";
$transaction = $api->getPendingTransaction("fc64be31e56a448879f9984599cafead466ec5b1a985c6ce8e6d45685c55b7d1");
echo json_encode($transaction, JSON_PRETTY_PRINT)."\n";
echo "===========\n\n";

echo "== List Assets ==\n";
$assets = $api->getAssets();
echo json_encode($assets, JSON_PRETTY_PRINT)."\n";
echo "===========\n\n";

echo "== Get Asset ==\n";
$asset = $api->getAsset('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
echo json_encode($asset, JSON_PRETTY_PRINT)."\n";
echo "===========\n\n";