mod bug solved ->Charly

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

mod bug solved ->Charly

Postby wilsongamboa » Wed Nov 10, 2021 5:23 pm

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 view

#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
User avatar
wilsongamboa
 
Posts: 549
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 5 guests