PHP code example of dawn-frost / pdd-sdk
1. Go to this page and download the library: Download dawn-frost/pdd-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/ */
dawn-frost / pdd-sdk example snippets
$clientId = "your app clientId";
$clientSecret = "your app clientSecret";
$refreshToken = "your app refreshToken";
$code = "your code";
$accessTokenClient = new PopAccessTokenClient($clientId,$clientSecret);
// 生成AccessToken
$result = $accessTokenClient->generate($code);
$result = json_encode($result->getContent(),JSON_UNESCAPED_UNICODE);
echo $result;
// 刷新AccessToken
$result = $accessTokenClient->refresh($refreshToken);
$result = json_encode($result->getContent(),JSON_UNESCAPED_UNICODE);
echo $result;
$clientId = "your app clientId";
$clientSecret = "your app clientSecret";
$pid = "your pid";
//创建client客户端
$client = new PopHttpClient($clientId, $clientSecret);
//创建请求对象
$request = new PddDdkGoodsDetailRequest();
$request->setGoodsIdList(array(6730722720));
$request->setPid($pid);
$request->setCustomParameters('str');
$request->setZsDuoId(1111111);
$request->setPlanType(1);
//发起接口请求
try{
$response = $client->syncInvoke($request);
} catch(DawnFrost\Pdd\PopHttpException $e){
echo $e->getMessage();
exit;
}
$content = $response->getContent();
//判断是否异常
if(isset($content['error_response'])){
echo "异常返回";
}
echo json_encode($content,JSON_UNESCAPED_UNICODE);