juffalow/finstatclient

FinStat API client

1.0.1 2017-01-11 21:26 UTC

This package is not auto-updated.

Last update: 2024-05-06 04:34:58 UTC


README

Packagist Packagist

API client for FinStat service.

Tech

This solution is using CURL. But if you have to use something else to make HTTP POST, there is no problem to do that :

<?php

require __DIR__ . '/vendor/autoload.php';

class NonCurlApiCall extends \juffalow\finstatclient\CurlApiCall {
    protected function httpPost($url, $params) {
        $options = array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($params)
            )
        );
        $context  = stream_context_create($options);
        $result = file_get_contents($url, false, $context);
        if($result === false) {
            throw \Exception('Error!');
        }
        return $result;
    }
}

$client = new juffalow\finstatclient\Client('<your API key>', '<your private key>', null, null, new NonCurlApiCall());

Example

This is basic example how to request for company detail.

<?php

require __DIR__ . '/vendor/autoload.php';

$client = new juffalow\finstatclient\Client('<your api key>', '<your private key>');

try {
    $detail = $client->getCompanyDetail('35757442');
} catch(\Exception $e) {
    print_r($e);
}

You can see more in example page.