tiktok shop api 获取密钥
官方链接 对接的晕头巴脑的
https://bytedance.feishu.cn/docs/doccnZtvJej6U1AMEuIqz60IYuS
成功之后 php版本的
<?php
class TiktokApi
{
use APITrait;
const api_url = [
'auth' => 'https://auth-sandbox.tiktok-shops.com',
'api' => 'https://open-api-sandbox.tiktokglobalshop.com',
/* 'prod_api' => '/api/seller/global/active_shops',
'prod_auth' => '/api/seller/global/active_shops'*/
];
const methods = [
'oauth' => '/oauth/authorize',//跳转认证
'getToken' => '/api/v2/token/get',//获取token
'getShop' => '/api/seller/global/active_shops',//获取可用店铺
];
public function postToTiktok($method, $data, $type)
{
}
public function getToTiktok($method, $data, $type)
{
$formatParams = http_build_query($data, '&');
$token_info = $this->getData(self::api_url[$type] . self::methods[$method] . '?' . $formatParams, "");
return json_decode($token_info, true);
}
/**
* $URL 请求方法
* $app_secret app密钥
* $data 请求数据
*/
public function getSign($method, $app_secret, $data)
{
$url = self::methods[$method];
$sign_array = [];
foreach ($data as $key => $datum) {
if (!in_array($key, ['sign', 'access_token'])) {
$sign_array[$key] = $datum;
}
}
asort($sign_array);
$sign_str = $app_secret . $url;
foreach ($sign_array as $key => $datum) {
$sign_str .= $key . $datum;
}
$sign_str.=$app_secret;
return hash_hmac('sha256', $sign_str, $app_secret);
}
}