这个感觉也不是很麻烦,得不到正确结果,还要找找原因,非Au3之过也。#NoTrayIcon
#RequireAdmin
#PRE_UseX64=n
#include <ACN_HASH.au3>
#include <Crypt.au3>
Local $secretKey = '123abc'
Local $from_appkey = 'CAKRVo*******'
Local $from_code = 'CAKRVo*******'
Local $to_appkey = 'sto_oms'
Local $to_code = 'sto_oms'
Local $api_name = 'OMS_EXPRESS_ORDER_CREATE'
Local $content = '{"waybillNo":"6606002282568"}'
Local $n = _Crypt_HashData($content & $secretKey, $CALG_MD5)
Local $data_digest = _Base64Encode($n)
ConsoleWrite($data_digest & @CRLF)
Local $postdata = "from_appkey=" & _StringToEncode($from_appkey, 4) & _
"&from_code=" & _StringToEncode($from_code, 4) & _
"&to_appkey=" & _StringToEncode($to_appkey, 4) & _
"&to_code=" & _StringToEncode($to_code, 4) & _
"&api_name=" & _StringToEncode($api_name, 4) & _
"&content=" & _StringToEncode($content, 4) & _
"&data_digest=" & _StringToEncode($data_digest, 4)
Local $http = ObjCreate('WINHTTP.WINHTTPREQUEST.5.1')
$http.Open('POST', 'http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do', True)
$http.SetRequestHeader("Accept", "*/*")
$http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$http.Send($postdata)
$http.WaitForResponse()
Local $oReturnWebS = BinaryToString($http.ResponseBody, 4)
ConsoleWrite($oReturnWebS & @CRLF)
Func _StringToEncode($str, $Encode = 1, $AllFlag = 0, $sPrefix = '%')
;afan 提示:转换字符串为ANSI;GB2312;URL;unicode等格式编码
;$str - 需转换的字符串
;$Encode - [可选参数]编码格式: 1(默认) = ANSI; 2 = UTF16 小; 3 = UTF16 大; 4 = UTF8
;$AllFlag - [可选参数] =0 不转换字母及数字(默认); =1 全部转换(字符头http://除外)
;$sPrefix - [可选参数]编码首字符
;返回值:成功 - 返回转换后的编码字符串; 失败 - 设置 @Error = 1
Local $str_s = StringRegExpReplace($str, '^\s*(?i)(http://).+', '$1')
If Not @extended Then $str_s = ''
If @extended Then $str = StringRegExpReplace($str, '^\s*(?i)http://', '')
Local $sOut, $i, $sS2B, $aSR
If $AllFlag Then
$sS2B = StringTrimLeft(StringToBinary($str, $Encode), 2)
$sOut = StringRegExpReplace($sS2B, '..', $sPrefix & '$0')
Else
$sOut = $str
$aSR = StringRegExp($str, '\W+', 3)
If Not @error Then
For $i = 0 To UBound($aSR) - 1
$sS2B = StringTrimLeft(StringToBinary($aSR[$i], $Encode), 2)
$sOut = StringReplace($sOut, $aSR[$i], StringRegExpReplace($sS2B, '..', $sPrefix & '$0'), 1)
Next
EndIf
EndIf
If $sPrefix = ' ' Then $sOut = StringRegExpReplace($sOut, "^\h+|\h+$", '')
;$sOut = StringReplace($sOut, '%20', '+') ;转换空格的编码为'+'号,也可不要此行
Return $str_s & $sOut
EndFunc ;==>_StringToEncode
|