0 WinHttp.WinHttpRequest简介
winhttp.winhttprequest是Windows操作系统中的一个API函数,用于创建和发送HTTP请求。它可以用于从Web服务器获取数据,或将数据发送到Web服务器。该函数提供了许多选项,例如设置请求头、设置代理服务器、设置超时时间等。它是一个非常强大的工具,可以帮助开发人员轻松地与Web服务器进行通信。
winhttp.winhttprequest.5.1
wihttp.winhttprequest.5.1是一个Microsoft Windows操作系统中的COM组件,用于在应用程序中进行HTTP请求和响应。它提供了一种简单的方法来与Web服务器进行通信,可以用于发送和接收HTTP请求和响应,支持各种HTTP方法,如GET、POST、PUT、DELETE等。它还提供了一些其他功能,如设置请求头、设置代理服务器、设置超时等。
1 创建PB窗口
为了演示winhttp.winhttprequest的使用创建一PB测试窗口w_restful如下:
窗口w_restful代码如下:
forward
global type w_restful from window
end type
type mle_resp from multilineedit within w_restful
end type
type st_3 from statictext within w_restful
end type
type cb_delete from commandbutton within w_restful
end type
type cb_put from commandbutton within w_restful
end type
type cb_post from commandbutton within w_restful
end type
type cb_get from commandbutton within w_restful
end type
type sle_data from singlelineedit within w_restful
end type
type sle_url from singlelineedit within w_restful
end type
type st_2 from statictext within w_restful
end type
type st_1 from statictext within w_restful
end type
end forward
global type w_restful from window
integer width = 3186
integer height = 1980
boolean titlebar = true
string title = "PB请求RESTful的数据"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mle_resp mle_resp
st_3 st_3
cb_delete cb_delete
cb_put cb_put
cb_post cb_post
cb_get cb_get
sle_data sle_data
sle_url sle_url
st_2 st_2
st_1 st_1
end type
global w_restful w_restful
forward prototypes
public subroutine wf_https (string as_method)
end prototypes
public subroutine wf_https (string as_method);string ls_url,ls_data
ls_url = sle_url.text
ls_data = sle_data.text
string ls_ret
ls_ret = gf_https_apex(ls_url,ls_data,as_method)
mle_resp.text = ls_ret
end subroutine
on w_restful.create
this.mle_resp=create mle_resp
this.st_3=create st_3
this.cb_delete=create cb_delete
this.cb_put=create cb_put
this.cb_post=create cb_post
this.cb_get=create cb