PHP code example of tansilu / tslopensdk
1. Go to this page and download the library: Download tansilu/tslopensdk 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/ */
tansilu / tslopensdk example snippets
$apiClient = new \com\tsl3060\open\sdk\ApiClient();
$conf = new \com\tsl3060\open\sdk\Config();
//应用APPID
$conf->setAppId("");
//应用私钥
$conf->setPrivateKey("");
//应用公钥
$conf->setPublicKey("");
//API 平台公钥
$conf->setApiPublicKey("");
$apiClient->setConfig($conf);
//设置通知数据监听
$apiClient->setNotifyListener();
$header = getallheaders();
$raw = file_get_contents("php://input");
try {
$no = $apiClient->notifyRun($header['Content-Type'], $raw);
header("Content-Type: application/json");
echo json_encode($no);
} catch (\com\tsl3060\open\sdk\exception\BadResourceException|\com\tsl3060\open\sdk\exception\UnknownResourceException $e) {
//输出异常
header('HTTP/1.1 500 Internal Server Error');
}