找回密码
 加入
搜索
查看: 10831|回复: 14

[系统综合] _winhttp_getrespond提交中文乱码

 火.. [复制链接]
发表于 2013-6-21 05:48:24 | 显示全部楼层 |阅读模式
本帖最后由 kxing 于 2013-6-21 19:54 编辑

该程序几乎成品了,可惜是发送中文字符就乱码。
在此贴上源码,新手拿去学习。望高人能解决这美中不足的地方。
希望 republican 等高人能出来解决,小弟不胜感激!!
#include "winhttp_getrespond.au3"
_sms_main()
func _sms_main()
local $hOpen=_winhttpopen()

$phonenum=inputbox("手机号码","请输入接收验证码的手机号:")
if not stringregexp($phonenum,"^\d{11}$") then return msgbox(48,"提示","您输入的手机号码不正确!")
_sms_getcheckcode($hOpen,$phonenum)
$checkcode=inputbox("验证码","请输入手机接收到的验证码:")
if not stringregexp($checkcode,"^\d+$") then return msgbox(48,"提示","您输入的验证码不正确!")

$loginRes=_winhttp_getrespond($hOpen,"http://115.239.133.251:6090/imweb/codeLoginForSouGou.s?clientId=51&channel=51&account="&$phonenum&"&checkCode="&$checkcode,2)
if @error then
msgbox(48,"抱歉","连接服务器失败,请稍后再试!")
return false
else
$res=binarytostring($loginRes[0])
if stringinstr($res,"100") then
msgbox(64,"OK","登陆成功!")
else;判断错误码
if stringinstr($res,"101") then
msgbox(48,"提示","您已连续5次输错验证码,请半小时后再试")
elseif stringinstr($res,"102") then
msgbox(48,"提示","验证码错误")
elseif stringinstr($res,"103") then
msgbox(48,"提示","验证码失效,请重新获取")
elseif stringinstr($res,"802") then
msgbox(48,"提示","验证码错误")
else 
msgbox(48,"提示","登录失败,请稍后再试")
endif
;return false
endif
endif


const $title="短信免费发"
if winexists("[REGEXPTITLE:^"&$title&"$]") then return winactivate("[REGEXPTITLE:^"&$title&"$]")


$hForm=guicreate($title,200,180)
guisetbkcolor(0x000000)
guictrlcreatelabel("对方手机:",10,10,60,20)
guictrlsetcolor(-1,0xffffff)
$hPhonenum=guictrlcreateinput("",70,10,100,20)
guictrlcreatelabel("发送内容:",0,0,0,0)
$hSendmsg=guictrlcreateedit("",0,40,200,100)
$hSendbut=guictrlcreatebutton("免费发送(Ctrl+回车)",30,150,140,20)
guisetstate()

while 1
switch guigetmsg()
case -3
_winhttpclosehandle($hOpen)
exit

case $hSendbut
$num=guictrlread($hPhonenum)
$text=guictrlread($hSendmsg)
_sms_sendmsg($hOpen,$num,$text,$checkcode)
endswitch
wend
endfunc;main

func _sms_getcheckcode($hOpen,$pNum)
$res=_winhttp_getrespond($hOpen,"http://115.239.133.251:6090/imweb/phoneCheckCode.s?sendPhone="&$pNum&"&methodType=getPhoneCode",2)
if @error then return false

$res=binarytostring($res[0])
if stringinstr($res,100) then
msgbox(64,"OK","验证码已经发送至您手机")
elseif stringinstr($res,103) then
msgbox(48,"提示","今天已经获取过10次已达上限")
elseif stringinstr($res,"104") then
msgbox(48,"提示","您获取验证码次数太频繁,请歇会再试")
elseif stringinstr($res,"105") then
msgbox(48,"提示","您已连续5次输错验证码,请半小时后再试")
else
msgbox(16,"错误","验证码获取失败")
endif
endfunc;getcheckcode

func _sms_sendmsg($hOpen,$num,$text,$chk)
$send="http://115.239.133.251:6090/imweb/smsPush.s?checkCode="&$chk&"&receivePhone="&$num&"&smsContent="&$text
$headers="x-requested-with: XMLHttpRequest"&@CRLF& _
"Accept-Language: zh-cn"&@CRLF& _
"Referer: http://115.239.133.251:6090/imweb/toSouGou/index.html"&@CRLF& _
"Accept: */*"&@CRLF& _
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8"&@CRLF& _
"Accept-Encoding: gzip, deflate"&@CRLF& _
"Connection: Keep-Alive"&@CRLF& _
"Cache-Control: no-cache"&@CRLF&@CRLF

$sendres=_winhttp_getrespond($hOpen,$send,2,-1,$headers)

$res=binarytostring($sendres[0])
if stringinstr($res,100) then
msgbox(64,"OK","短信已成功发送!")
else
msgbox(16,"错误","短信发送失败,可能验证码已失效,请重新获取!")
endif
clipput($res)
endfunc;sendmsg
 楼主| 发表于 2013-6-21 05:56:27 | 显示全部楼层
我尝试过将短信内容用unicode编码过也是不行。

原POST抓包数据:

POST /imweb/smsPush.s?clientId=51 HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: zh-cn
Referer: http://115.239.133.251:6090/imweb/toSouGou/index.html
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)
Host: 115.239.133.251:6090
Content-Length: 193
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=A2AEDACC5D21AC6663C0D6AEF7EC9E60



-------------------------

checkCode=%E6%A0%A1%E9%AA%8C%E7%A0%81&receivePhone=11位手机号&smsContent=hello+123.%E3%80%82%E3%80%82%E5%93%A6%E5%8F%91%E7%BB%99%E8%B0%81&fileUrl=&fileSize=&fileName=&random=0.5231676247708166
发表于 2013-6-21 13:00:55 | 显示全部楼层
楼主高淫,帮顶了...
发表于 2013-6-21 13:19:14 | 显示全部楼层
没实用价值! 只能发5条
还要手机验证码!
发表于 2013-6-21 17:49:48 | 显示全部楼层
有想法  不错
 楼主| 发表于 2013-6-22 09:03:52 | 显示全部楼层
顶起来,望高人看见。。。
发表于 2013-6-22 16:02:17 | 显示全部楼层
Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Line 84 $text

轉成urlencoded(UTF-8)再發送出去
 楼主| 发表于 2013-6-23 17:43:00 | 显示全部楼层
回复 7# Duvet

试过了,还是乱码啊。。。
发表于 2013-6-23 19:35:45 | 显示全部楼层
不是unicode编码

$send = "http://115.239.133.251:6090/imweb/smsPush.s?" & _
                "checkCode=" & $chk & _
                "&receivePhone=" & $num & _
                "&smsContent=" & _Encode($text)
                        
Func _Encode($sText)
        Local $oSC = ObjCreate("ScriptControl")
        If @error Then Return SetError(-1, 0, $sText)
        $oSC.language = "JavaScript"
        Return $oSC.eval("encodeURIComponent('" & $sText & "');")
EndFunc
 楼主| 发表于 2013-6-24 03:44:24 | 显示全部楼层
回复 9# Duvet


老兄,我用的就是此编码啊    ,不行哦。
难道你测试没问题??
发表于 2013-6-26 21:56:49 | 显示全部楼层
看看怎么样啊  学习中···
发表于 2013-6-26 23:04:13 | 显示全部楼层
好久没回了,周末看看。

其他大大都不在啦?
发表于 2013-6-26 23:41:33 | 显示全部楼层
回复 1# kxing

请使用POST而非GET提交转义字符。
 楼主| 发表于 2013-6-27 01:52:33 | 显示全部楼层
本帖最后由 kxing 于 2013-6-27 01:54 编辑

post也试过了,一样乱码。
 楼主| 发表于 2013-6-30 05:26:08 | 显示全部楼层
高人们出来驻站下啊....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-25 00:22 , Processed in 0.077748 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表