PHP SDK
php sdk
- Version iteration log
Development language | Support | Version | Notes | Download address |
---|---|---|---|---|
php | Yes | 1.0.1 | bate version | Click to download |
Error handling
Interface request error, verification failed. Will be thrown as ServiceException, please handle the exception log by yourself
It is recommended to use composer to introduce
composer require duomai/cps-client
Call example
use Duomai\CpsClient\Client;
use Duomai\CpsClient\Endpoints\Products;
// Initialize configuration information
$config = [
"host" => "https://platform.duomai.com/apis/",
"auth" => [
"app_key" => "",
"app_secret" => "",
]
];
$client = new Client($config);
// url to get promotion link
$data = $client->chanLinkForUrl(27, "https://item.jd.com/44034746681.html");
// plan to get the promotion link
$data = $client->chanLinkForAds(27, 61);
// Example of getting promotional links from JD.com Including original link information
$data = $client->chanLink(27, 0, 61, "https://item.jd.com/53272656742.html", [
"coupon" => "https://coupon.m.jd.com/coupons/show.action?linkKey=AAROH_xIpeffAs_-naABEFoe4cBnSa8GxbSbocVNklnakmZjGOpm7ZvMCCXXyopOOQqE2L6xWeg84IwUhjTLFasN",
"euid" => "test",
], true);
// Get short link
$ Url = $ client-> shortLink ( "https://union-click.jd.com/jdc?e=16282&p=AyIGZRtSFgQUB1ISUhIyFgVWHVgSBhUBUBhrUV1KWQorAlBHU0VeBUVOWk1RAk8ECllHGAdFBwtaV1MJBAJQXk8JF0EfGQYQBFMYXBEFFAJWDBsZdWt7Nm8SQFxlfj1%2FL2ZXRWcKbC1iYWVEI2k7cWJmbBBsOXFgcl5VXCxsdndkMXtddXBuVyJvOxNiYGMNbBJ%2BXWYFMXsvTGFFYB18JHV2YkUCTTBecVt7U2wibVFxZD5ELHxmQmcMbBp1WnF1IkI4S2FaZwZ7AWpAZn4PfS9hfVV%2FLEk5YXFbQiNyM3F1WmdBGS4lYVtsK1sMEXxyDjMZA28cGlNcQyMTch4LZRxeEgQbDlAfaxUFEQ5WK1sUBRYGUh5YJQITNxR1WxQCFA5VG1slAyIHURNeFgsbA1wfWREKIgddHGvBl7nf3owJVEDLt%2FDN8bsyIjdWK1sSARsEZStbFjIRNwt1WkYCGlNdTlx7WEBTCRMOTAF8BFIeWxQBEwVlGVoUABA%3D
");
print_r($url);
// Duomai link encryption and decryption
// encryption
$url = $client->encryptLink("https://c.duomai.com/track.php?site_id=27&lid=99&pf=dxk&skuid=53272656742&aid=61&euid=test&t=https%3A%2F%2Fcoupon.m.jd. com%2Fcoupons%2Fshow.action%3FlinkKey%3DAAROH_xIpeffAs_-naABEFoe4cBnSa8GxbSbocVNklnakmZjGOpm7ZvMCCXXyopOOQqE2L6xW84IwUhIMTLFasNb53j1eg
");
print_r($url."\n");
// decrypt
$url = $client->decryptLink($url);
print_r($url."\n");
// Jingdong product list
$data = $client->productList([
"query"=>"Coke"
]);
// 1688 product list
$data = $client->productList([
"query"=>"Coke"
],Products::PLATFORM_1688);
// A list of like products
$data = $client->productList([], Products::PLATFORM_YOUZAN);
// Pinduoduo product list
$data = $client->productList([
"query"=>"Coke"
], Products::PLATFORM_PDD);
// Koala product list
$data = $client->productList([
"query"=>"Coke"
], Products::PLATFORM_KAOLA);
// Vipshop product list
$data = $client->productList([
"query"=>"Coke"
], Products::PLATFORM_VIP);
// Suning product list
$data = $client->productList([
"query"=>"Coke"
], Products::PLATFORM_SUNING);