回复 1# coolybin
可以这样,直接POST提交数据到服务器. 获取返回的图片链接使用.
#cs 构造的请求头
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Host pic.kuche.com
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0
Content-length 168911
Content-type application/x-www-form-urlencoded
File-Extensions jpg
Pic-Bulk 0,0,0
Pic-Cut 0*0*0*0,0*0*0*0,0*0*100*75
Pic-IsAddWaterPic True,False,False
Pic-Path /p1/big/,/p1/small/,/p1/tiny/
Pic-Size 640*0,240*0,100*75*3
Pic-dpi 0,0,0
pic-name /p1/tiny/
#ce
Local $fp=FileOpen(@ScriptDir&"\img.jpg",0+16)
Local $oHTTP = 0 ,$submitUrl="http://pic.kuche.com/" , $postData=FileRead($fp)
FileClose($fp)
$WinHttp = ObjCreate("WinHttp.WinHttprequest.5.1")
;设置参数
$WinHttp.SetTimeouts(60000, 60000, 60000, 3000) ;设置操作超时时间
$WinHttp.Option(4) = 13056 ;忽略错误标志
$WinHttp.Option(6) = False ;为 True 时,当请求页面重定向跳转时自动跳转,False 不自动跳转,截取服务端返回的302状态。
$WinHttp.Open( "POST", $submitUrl, False) ;GET 或 POST, Url, False 同步方式;True 异步方式
;组成 HTTP 头信息
$WinHttp.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") ;接受数据类型
$WinHttp.SetRequestHeader("Accept-Language", "zh-cn,zh") ;用户系统语言
$WinHttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0") ;用户浏览器信息
$WinHttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") ;编码方式
$WinHttp.SetRequestHeader("Host", "pic.kuche.com")
$WinHttp.SetRequestHeader("Connection", "Keep-Alive") ;Close = 不保持连接,Keep-Alive = 保持连接(持久连接)
$WinHttp.SetRequestHeader("Accept-Encoding", "gzip, deflate" );如果发送,会返回 gzip, deflate 压缩过的编码
$WinHttp.SetRequestHeader("Content-Length", StringLen($postData) );内容长度,Post 方式用的。
$WinHttp.SetRequestHeader("File-Extensions", "jpg")
$WinHttp.SetRequestHeader("Pic-Bulk", "0,0,0")
$WinHttp.SetRequestHeader("Pic-Cut", "0*0*0*0,0*0*0*0,0*0*100*75")
$WinHttp.SetRequestHeader("Pic-IsAddWaterPic", "True,False,False")
$WinHttp.SetRequestHeader("Pic-Path", "/p1/big/,/p1/small/,/p1/tiny/")
$WinHttp.SetRequestHeader("Pic-Size", "640*0,240*0,100*75*3")
$WinHttp.SetRequestHeader("Pic-dpi", "0,0,0")
$WinHttp.SetRequestHeader("pic-name", "/p1/tiny/")
;发送数据
$WinHttp.Send($postData)
ConsoleWrite("LoginIn "&$WinHttp.Status&@CRLF) ;当前 HTTP 状态
$WinHttp.WaitForResponse ;等待返回请求,XMLHTTP中也可以使用
ConsoleWrite($WinHttp.ResponseText&@CRLF) ;
InetGet("http://pic.58.com/p1/tiny/"&$WinHttp.ResponseText,$WinHttp.ResponseText)
|