kolrank / api
the api sdk of kolrank open platform
v0.1
2018-12-14 07:39 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.2
- monolog/monolog: ^1.22
- pimple/pimple: ^3.0
- symfony/cache: ^3.3
This package is auto-updated.
Last update: 2024-11-14 20:52:09 UTC
README
kolrank api sdk,http://open.koldata.net/ http://www.kolrank.com
Requirement
- PHP >=7.0
- Composer
Installation
composer require kolrank/api:v0.1
Usage
Overview
<?php use Kolrank\Sdk\Api\Factory; //require __DIR__.'/vendor/autoload.php'; //you should require composer autoload file // this is config $config = [ 'app_id' => 'app_id', 'app_secret' => 'app_secret', 'username' => 'username', 'password' => 'password', 'response_type' => 'array',// return type : array collection json xml 'log' => [//log config ,useing debug please when develop 'default' => 'prod', 'prod' => [ 'level' => 'info' ] ] ]; $app = Factory::kolrank($config); $wechat = $app->wechat; $info = $wechat->info('lengtoo'); var_dump($info);
configure
$config = [ 'app_id' => 'app_id', 'app_secret' => 'app_secret', 'username' => 'username', 'password' => 'password', 'response_type' => 'array',// return type : array collection json xml // logs 'log' => [ 'default' => 'dev', // default channel, 'channels' => [ // test env 'dev' => [ 'driver' => 'single', 'path' => '/tmp/kolrank.log', 'level' => 'debug', ], // production env 'prod' => [ 'driver' => 'daily', 'path' => '/tmp/kolrank.log', 'level' => 'info', ], ], ], // http info 'http' => [ 'max_retries' => 1, 'retry_delay' => 500, 'timeout' => 5.0, // 'base_uri' => 'http://open.koldata.net/, ], ]
Some API
<?php use Kolrank\Sdk\Api\Factory; $app = Factory::kolrank($config); //__callstatic magic method, Factory::make($config);Factory::otherMehotd($config); $wechat = $app->wechat;//get wechat client instance ,auto auth $info = $wechat->info('rmrbwx'); $weibo = $app->weibo;//get weibo client instance ,auto auth $info = $weibo->info(2270576952); $accessToken = $app->access_token;//get token instance $tokenInfo = $accessToken->getToken();//setToken() if you want to use an exists token
Custom Cache
access_token use cache,
the cache implements symfony/cache,
for example:
<?php use Symfony\Component\Cache\Simple\RedisCache; // create redis instance $redis = new Redis(); $redis->connect('redis_host', 6379); // create redis cache instance $cache = new RedisCache($redis); // rebind cache instance $app->rebind('cache', $cache);