- Code: Select all Expand view
- function Main()
AP_SetContentType( "application/json" )
?? hb_jsonEncode( { "Method" => AP_Method(), "Args" => AP_Args(), "Body" => AP_Body() } )
return nil
live demo:
https://fivetechsoft.github.io/snippets?20200224184548
Accessing the webservice from mod_harbour:
- Code: Select all Expand view
- #include "/home/user/harbour/contrib/hbcurl/hbcurl.ch"
function Main()
? UseWebService()
return nil
function UseWebService()
local uValue
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, "http://www.modharbour.org/modharbour_samples/webservice.prg" )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, hb_jsonEncode( { "key1" => "value1", "key2" => "value2", "key3" => "value3" } ) )
if curl_easy_perform( hCurl ) == 0
uValue = curl_easy_dl_buff_get( hCurl )
endif
endif
curl_global_cleanup()
return uValue