PHP code example of maxzhang / dataoke-sdk
1. Go to this page and download the library: Download maxzhang/dataoke-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/ */
maxzhang / dataoke-sdk example snippets
use MaxZhang\DataokeSdk\Request\Govbus\CategoryGetRequest;
use MaxZhang\DataokeSdk\DefaultDataokeClient;
$req = new CategoryGetRequest();
$assertArray = [
'serverUrl' => 'https://openapi.dataoke.com',
'appKey' => 'b49970b52c88dee1d7c1743da32cedd2',
'appSecret' => '2ae2da81c64ae149c2aeb99a535508b0'
];
$client = new DefaultDataokeClient($assertArray['serverUrl'], $assertArray['appKey'],
$assertArray['appSecret']);
$resp = $client->execute($req);
$reqJson = $req->getReqJson();
print_r("请求报文:\n" . $reqJson);
print_r("\n返回响应报文:\n" . $resp);
'providers' => [
...
MaxZhang\DataokeSdk\ServiceProvider::class
],
'dataokeSdk' => [
'appKey' => env('DATAOKE_SDK_APPKEY'),
'appSecret' => env('DATAOKE_SDK_APPSECRET'),
'serverUrl' => env('DATAOKE_SDK_SERVERURL')
],
DATAOKE_SDK_APPKEY= 你的appkey
DATAOKE_SDK_APPSECRET= 你的appSecret
DATAOKE_SDK_SERVERURL=https://openapi.dataoke.com
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use MaxZhang\DataokeSdk\Request\Govbus\CategoryGetRequest;
use MaxZhang\DataokeSdk\DefaultDataokeClient;
class CategoryGet extends Controller
{
public function show(Request $request)
{
$req = new CategoryGetRequest();
$resp =app('dataokeSdk')->execute($req);
$reqJson = $req->getReqJson();
print_r("请求报文:\n" . $reqJson);
print_r("\n返回响应报文:\n" . $resp);
$request->json($resp);
}
}
public function show(DefaultDataokeClient $defaultDataokeClient)
{
...
$response = $defaultDataokeClient->execute('$req');
}
public function show()
{
...
$response =app('dataokeSdk')->execute($req);
}