gpt4 book ai didi

php - 如何使用 PHP 为 Aliexpress API 生成 _aop_signature?

转载 作者:行者123 更新时间:2023-12-02 03:52:06 28 4
gpt4 key购买 nike

我正在使用 Aliexpress APIgeneratePromotionLinks。此 API 需要一个参数 _aop_signature

网址是这样的:

https://gw.api.alibaba.com/openapi/param2/1/portals.open/api.generatePromotionLinks/[appKey]?trackingId=[trackingId]&targetUrls=[url]&locale=[global]&linkType=HOT_PRODUCT_LINK&_aop_signature=[signature]

我想知道在哪里可以获得 _aop_signature,或者如何使用 PHP 生成 _aop_signature

最佳答案

<?php
$url = 'https://gw.api.alibaba.com/openapi/';
$appKey = ***;
$appSecret ='***';
$apiInfo = 'param2/1/portals.open/api.generatePromotionLinks/' . $appKey;
$code_arr = array(
'urls' => 'https://ru.aliexpress.com/af/mp3.html?d=y&origin=n&SearchText=mp3&catId=0&initiative_id=SB_20191106040548',
'linkType' => 'SEARCH_LINK',
'fields' => 'promotionUrls,trackingId,publisherId',
'trackingId' => 'Please create a unique affiliate ID for your site(s).',

);
$aliParams = array();
foreach ($code_arr as $key => $val) {
$aliParams[] = $key . $val;
}
sort($aliParams);
$sign_str = join('', $aliParams);
$sign_str = $apiInfo . $sign_str;
$code_sign = strtoupper(bin2hex(hash_hmac("sha1", $sign_str, $appSecret, true)));

$url = $url.$apiInfo.'?'.http_build_query($code_arr)."&_aop_signature=".$code_sign;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
?>

关于php - 如何使用 PHP 为 Aliexpress API 生成 _aop_signature?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55805101/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com