PHP code example of jdrent / jdrent-php-sdk
1. Go to this page and download the library: Download jdrent/jdrent-php-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/ */
jdrent / jdrent-php-sdk example snippets
use JDRent\Config\Config;
$config = new Config();
// 应用ID
$config->setAppId('your_app_id');
// 服务端密钥系统类型,无特殊要求不需要修改
$config->setJddKeyType('AKS');
// 服务端公钥
$config->setOpenPublicKey('your_public_key');
// 客户端私钥
$config->setAppPrivateKey('your_private_key');
// 加密算法,支持3DES_RSA、NONE
$config->setEncryptType('3DES_RSA');
// 加签算法,支持SHA256withRSA
$config->setSignType('SHA256withRSA');
// 用户类型,默认0,无特殊要求不需要修改
$config->setAppIdType("0");
// 服务端调用地址!测试: https://test-api.jddglobal.com、生产: https://api.jddglobal.com
$config->setServer('https://api.jddglobal.com');
use JDRent\Client\DefaultJddClient;
use JDRent\Request\RentOrderCreateRequest;
二、组织业务参数
$request = new RentOrderCreateRequest();
$request->setOutOrderNo('ORDER_001');
// 三、配置api地址
$apiMethod = '/smapi/v1/rent/order/create';
// 四、发起调用
$response = $defaultJddClient->execute($request, $apiMethod);
// 五、响应结果
echo json_encode($response, JSON_UNESCAPED_UNICODE);
use JDRent\Client\DefaultHapiJddClient;
'sysId' => '123',
'token' => '456'
];
$param = [
"processId" => "262",
"openSys" => "A20200702110",
"openId" => "YFKLXD001",
"openUser" => "YFKLXD001",
"successUrl" => "",
"clientIp" => $_SERVER['REMOTE_ADDR'],
"failUrl" => "",
"openApiParam" => "{'backUrl':'www.jd.com'}",
];
$data = ["param" => $param, "systemInfo" => $systemInfo];
$reqData = ["data" => $data];
// 发起页面跳转
$client = new DefaultHapiJddClient($config);
$result = $client->getData($reqData);
use JDRent\Client\DefaultSpiJddClient;
use JDRent\Support\Util\DateUtil;
aultSpiClient->receive($httpServletRequest);
// 业务逻辑处理
$spiResponse = [
"resultParams" => $bizContent,
"code" => "00000",
"msg" => "成功",
"respondTime" => DateUtil::getMicrosecondTime()
];
$responseWriter = $defaultSpiClient->callback($httpServletRequest, $spiResponse);
// $responseWriter['http_body'] 是响应给服务端的body
// $responseWriter['http_headers'] 是响应给服务端的header
use JDRent\Client\DefaultNapiJddClient;
$config);
$notifyContent = $napiClient->getBizContent($httpServletRequest);
echo $notifyContent;
// 响应服务端'ok'
return 'ok';
bash
composer