几个月来第一篇文章
吐槽下币安的aws服务,对于不同地区服务器访问,aws cloudfont 限制不同。
我有日本亚马逊服务器 也有 香港谷歌服务器,真的是不同服务不同待遇。
先说本文章的问题, 请求 万向划转接口 /sapi/v1/sub-account/universalTransfer
存在 fromEmail
/ toEmail
两个参数, 邮箱参数中存在 @
PHP 中 将请求参数 生成 URL-encode
之后的请求字符串 放置 Post HTTP Body
中 或 URI
中 币安的接口都是支持的。
$query = http_build_query($params, '', '&');
curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
上面的方法处理后的串,果然包含@
符号就会转义成 %40,上面 $query post 我们将其放入HTTP Body中, 接收端获取POST请求参数验签 由于 @ 变成 %40 就会失败。
解决方案 POST 请求参数如果放入 HTTP Body 内的参数 需要 进行 urldecode 解码;
$query = urldecode(http_build_query($params, '', '&'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $query);