提交 b4cddc89 作者: 黄程泽

签名调整

上级 ddbd9175
# 游戏 SDK 对接文档-v1.0 # 游戏 SDK 对接文档-v1.0
...@@ -324,9 +324,16 @@ sequenceDiagram ...@@ -324,9 +324,16 @@ sequenceDiagram
```php ```php
<php? <php?
$gameSecret = "game_secret"; $gameSecret = "game_secret";
$body = ["player_id" => 1245, "game_id" => 14]; $params = ["player_id" => 1245, "game_id" => 14];
ksort($body, SORT_REGULAR); $signStr = '';
$signStr = http_build_query($body)."&game_secret=".$gameSecret; ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
$val = json_encode($val, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
$sign = md5($signStr); $sign = md5($signStr);
``` ```
...@@ -384,9 +391,16 @@ sequenceDiagram ...@@ -384,9 +391,16 @@ sequenceDiagram
$response = curl_post($url, $body, $hearders); $response = curl_post($url, $body, $hearders);
} }
public function makeSign($body, $Secret){ public function makeSign($params,$gameSecret){
ksort($body, SORT_REGULAR); $signStr = '';
$signStr = http_build_query($body)."&game_secret=".$gameSecret; ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
$val = json_encode($val, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
return md5($signStr); return md5($signStr);
} }
...@@ -488,11 +502,19 @@ sequenceDiagram ...@@ -488,11 +502,19 @@ sequenceDiagram
$response = curl_post($url, $body, $hearders); $response = curl_post($url, $body, $hearders);
} }
public function makeSign($body, $Secret){ public function makeSign($params,$gameSecret){
ksort($body, SORT_REGULAR); $signStr = '';
$signStr = http_build_query($body)."&game_secret=".$gameSecret; ksort($params, SORT_REGULAR);
foreach ($params as $key => $val) {
if (is_array($val)) {
$val = json_encode($val, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
}
$signStr .= $key . '=' . $val . '&';
}
$signStr .= 'game_secret=' . $gameSecret;
return md5($signStr); return md5($signStr);
} }
public function curl_post($url, $body, $headers){ public function curl_post($url, $body, $headers){
//初始化 //初始化
$curl = curl_init ( ) ; $curl = curl_init ( ) ;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论