PHP code example of stk2k / phitflyer

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

    

stk2k / phitflyer example snippets


use Stk2k\PhitFlyer\PhitFlyerClient;

$client = new PhitFlyerClient();
 
$markets = $client->getMarkets();
 
foreach($markets as $idx => $market){
    echo $idx . '.' . PHP_EOL;
    echo 'product_code:' . $market->product_code . PHP_EOL;
    echo 'alias:' . (isset($market['alias']) ? $market['alias'] : '') . PHP_EOL;
}
 

use Stk2k\PhitFlyer\PhitFlyerClient;
use Stk2k\PhitFlyer\PhitFlyerObjectClient;

$client = new PhitFlyerObjectClient(new PhitFlyerClient());
 
$markets = $client->getMarkets();
 
foreach($markets as $idx => $market){
    echo $idx . '.' . PHP_EOL;
    echo 'product_code:' . $market->getProductCode() . PHP_EOL;
    echo 'alias:' . $market->getAlias() . PHP_EOL;
}
 

use Stk2k\PhitFlyer\PhitFlyerClient;
use Stk2k\PhitFlyer\PhitFlyerBenchmarkClient;

$client = new PhitFlyerBenchmarkClient(
            new PhitFlyerClient(), 
            function ($m, $e) use(&$method, &$elapsed){
                 echo "[$m]finished in $e sec" . PHP_EOL;
             }
        );
 
$client->getMarkets();
 

use Stk2k\PhitFlyer\PhitFlyerClient;
use Stk2k\PhitFlyer\PhitFlyerLoggerClient;

$client = new PhitFlyerLoggerClient(
    new PhitFlyerClient(),
    new YourLogger()    // YourLogger: Psr-3 compliant logger
);
$client->getNetDriver()->setVerbose(true);      // ouput detail log

use Stk2k\PhitFlyer\PhitFlyerClient;
use Stk2k\NetDriver\NetDriver\Php\PhpNetDriver;

$client = new PhitFlyerClient();
$client->setNetDriver(new PhpNetDriver());      // use file_get_contents to call web api instead of cURL function

$markets = $client->getMarkets();