PB中打開url鏈接
公司項目中,第三方發來個說明,說是要通過打開url連接地址的方式,將參數傳給對方的平臺,參數的封裝採用Json格式,
百度了一通,看了網友們的方法,發現pb中有個inet控件可以實現功能,我開始想,應該是將參數傳給對方以後,對方同
樣將返回值以json的格式傳給我們,所以,用戶不需要看到url打開的頁面,所以需要使用的是GetURL方法,並獲取返回值,
於是有了以下的方法
/*先建立一個nuo_cst_internet.sru對象,來獲取返回值*/ forward global type nuo_cst_internet from internetresult end type end forward global type nuo_cst_internet from internetresult end type global nuo_cst_internet nuo_cst_internet type variables string is_data end variables forward prototypes public function integer internetdata (blob data) end prototypes public function integer internetdata (blob data);is_data = string(data) return 1 end function on nuo_cst_internet.create call super::create TriggerEvent( this, "constructor" ) end on on nuo_cst_internet.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
以GetURL方法調用url地址
/*uf_get_url string as_url //封裝好的url地址 return string */ string ls_result integer li_rc inet linet_main nuo_cst_internet luo_data linet_main = CREATE inet luo_data = CREATE nuo_cst_internet li_rc = linet_main.GetURL(as_url, luo_data) ls_result = luo_data.is_data DESTROY luo_data DESTROY linet_main RETURN ls_result
後來發現,對方傳過來的也是一個網頁,然後還需在這個頁面的做提交,於是最後採用了HyperLinkToURL方法,於是不用獲取返回值了
string ls_result integer li_rc inet linet_main linet_main = CREATE inet li_rc = linet_main.HyperLinkToURL(as_url) RETURN li_rc