Get data from the Internet

Create a new userobject from standard class internetresult, call it n_cst_internet.
Declare this instance variable

string is_data


With that userobject type, you need to overload the internetdata function (which will be called by the PB VM automatically). The return type is integer and the parameter is data, its type is a blob.

[integer internetdata(blob data)]

is_data = string(data)
RETURN 1

Then from your script integer li_rc
inet linet_main
n_cst_internet luo_data  // as defined above

linet_main = CREATE inet
luo_data = CREATE n_cst_internet

SetPointer(HourGlass!)
li_rc = &
 linet_main.GetURL("http://www.rgagnon.com/classes/java-io.dat", luo_data)
SetPointer(Arrow!)
IF li_rc = 1 THEN
  MessageBox("Data from Real's HowTo", luo_data.is_data)
ELSE
  MessageBox("Data from Real's HowTo", "Oops rc:" + string(li_rc))
END IF

DESTROY luo_data
DESTROY linet_main

POSTing data maybe a little more tricky. You may need to set all the headers. string httprequest,ls_header
String ls_url,ls_headers
long ll_ret
long ll_length
Blob lblb_args
inet linet_main
n_cst_internet luo_data

linet_main = CREATE inet

luo_data = CREATE n_cst_internet

ls_url = "http://localhost/mypage.jsp"
lblb_args = blob("foo=bar")
ll_length = Len(lblb_args)
ls_headers = "Content-Type: " + &
      "application/x-www-form-urlencoded~n" + &
      "Content-Length: " + String( ll_length ) + "~n~n"
ll_ret = libet_main.PostURL(ls_url,lblb_args,ls_headers,8080,luo_data)

Tags:
作者:ccczqh | 时间:April 19, 2007 15:27 | 分类:编程开发 » powerbuilder | 评论(0) | 阅读(246)
发表评论
 昵称 [注册]
 密码 (游客无需密码)
 网址
 电邮
打开HTML 打开UBB 打开表情 隐藏 记住我