x.html
5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<style>
pre{
background-color: #f0f0f0;
}
</style>
<h3><div style="text-align:center">深圳国际贸易单一窗口业务对接创贸集团技术方案</div></h3>
<p>> 一. 签名</p>
<ol>
<li>签名采用rsa 2048</li>
</ol>
<pre>
<code class="language-injectablephp">
/**
* rsa 签名
* @param array $data 请求的参数
* @return string 签名字符串
*/
function rsaEnSign(array $data){
ksort($data);
$dataString = http_build_query($data);
if (openssl_sign($dataString, $signature, 'private_key', OPENSSL_ALGO_SHA1)) {
return base64_encode($signature);
} else {
return '';
}
}
</code>
</pre>
<ol start="2">
<li>验证数据</li>
</ol>
<pre>
<code class="language-injectablephp">
/**
* 验证数据来源
* @param array $data
* @param string $sign
*/
function rsaVerify(array $data, string $sign){
ksort($data);
$dataString = http_build_query($data);
$verified = openssl_verify($dataString, base64_decode($sign), 'public_key', OPENSSL_ALGO_SHA1);
if ($verified === 1) {
// 验证成功
} elseif ($verified === 0) {
// 验证失败
} else {
// 签名错误
$errorMsg = openssl_error_string();
}
}
</code>
</pre>
<p>> 二. 接口</p>
<ol>
<li><p>用户授权</p>
<ul>
<li>请求地址 /api/southern/auth</li>
<li>请求类型 POST</li>
<li>签名规则 rsa</li>
<li>请求示例</li>
</ul>
<pre>
<code class="language-injectablephp">
$postData = [
'payload' => [
"serviceFlowId" => "本次业务操作流水id",
"uniCode" => "南方电子口岸给对接方分配的 唯一ID号",
"mobile" => "手机",
"userId" => "用户 ID",
"userName" => "用户名称",
"entName" => "企业名称",
"scCode" => "企业统一社会信用代码"
],
'sign' => '',
];
$postData['sign'] = rsaEnSign($postData['payload']);
$result = Http::post('url', $postData);
if($result['code']===200){
// 成功
}else{
// 失败
}
</code>
</pre>
<ul>
<li>返回结果 成功</li>
</ul>
<pre>
<code class="language-json">
{
"code": 200,
"message": "SUCCESS",
"data": {
"url": [
{
"name": "ai搜索",
"url": "https://fob.ai.cc/ai_search?iframe_sign=xxxxx"
},
{
"name": "企业洞察",
"url": "https://fob.ai.cc/ai_company_search?iframe_sign=xxxxx"
},
...
],
"uniCode": "1",
"firstLogin": true //是否第一次登录
},
"success": true
}
</code></pre>
<ul>
<li>失败信息</li>
</ul>
<pre>
<code class="language-json">
{
"code": 500,
"message": "签名验证失败",
"success": false
}
</code>
</pre>
</li>
<li><p>意向登记</p>
<ul>
<li>请求地址 /api/southern/intention</li>
<li>请求类型 POST</li>
<li>签名规则 rsa</li>
<li>请求示例</li>
</ul>
<pre><code class="language-injectablephp">
$postData = [
"guid"=>"166970C4-AF54-470A-87E4-D598463783A2",
"busiCode"=> "CMJT04",
"senderId"=> "XXXXXX",
"version"=> "1.0",
'payload' => [
"serviceFlowId"=> "F2310011420000001",
"orgName"=>"xxx",
"orgCode"=>"xxx",
"userId"=>"xxx",
"userName"=>"xxxxx 有限公司",
"contactAddress"=> "xxxxxxxxxxxxxxxxxx",
"contactMan"=> "xxx",
"contactTel"=> "xxx",
"email"=> "xxx",
"position"=> "xxx",
"notes"=> "xxx"
],
'sign' => '',
];
$postData['sign'] = rsaEnSign($postData['payload']);
$result = Http::post('url', $postData);
if($result['code']===200){
// 成功
}else{
// 失败
}
</code></pre>
<ul>
<li>返回结果 成功</li>
</ul>
<pre>
<code class="language-json">
{
"code": 200,
"message": "SUCCESS",
"data": {
"serviceFlowId": "F2310011420000001",
"status": "11",
"statusTime": "20230818081331",
"statusDetail": ""
},
"success": true
}
</code>
</pre>
<ul>
<li>失败信息</li>
</ul>
<pre><code class="language-json">
{
"code": 500,
"message": "签名验证失败",
"success": false
}</code></pre>
</li>
</ol>
</body>
</html>