mod bug solved ->Charly

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
User avatar
wilsongamboa
Posts: 614
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador
Been thanked: 5 times

mod bug solved ->Charly

Post by wilsongamboa »

Good afternoon to everyone
Thanks to the invaluable work of our GURU Charly has solved a bug in the Mod_Harbour regarding the use of CURL when calling a WebService Thank you Charly!!
now it works perfect!! because the parameters did not receive them!!
this already works Ok

Code: Select all | Expand


#include "{% hb_getenv('PRGPATH') + '/hbcurl.ch' %}"

function Main()
   
    local h := UseWebService()
   
    AP_SetContentType( "application/json" )
   
    ?? hb_jsonEncode(h)

retu nil

function UseWebService()

    local uValue, hCurl
    local cUrlWs        := '190.110.XXX.YYY:6263/pre/jnetws/auth'
    local hHeaders  := { 'Content-Type: application/json' }  
    local hParams       := {=>}
    local h             := {=>}
    local n


    hParams[ 'wsuser' ]     := 'app1'
    hParams[ 'wspsw' ]  := 'acvbs'
    hParams[ 'user' ]       := 'demo'
    hParams[ 'psw' ]        := '1129'
    hParams[ 'emp' ]        := 'Empre003'

    curl_global_init()

    if ! empty( hCurl := curl_easy_init() )

        curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0)            
        curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlWs )
        curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, hHeaders )
        curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )  
        curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, hb_jsonEncode( hParams ) )

        curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )        
       
        n := curl_easy_perform( hCurl )
       
        if n == 0
       
            uValue  := curl_easy_dl_buff_get( hCurl )          
            h       := hb_jsonDecode( uvalue )
           
        else
            h[ 'error' ] := curl_easy_strerror( n )
        endif
    endif

    curl_global_cleanup()

return h
 
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Post Reply