#include "c:\harbour\contrib\hbcurl\hbcurl.ch"
function sendSMS( cUrl )
local uValue
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
if curl_easy_perform( hCurl ) == 0
uValue = curl_easy_dl_buff_get( hCurl )
endif
endif
curl_global_cleanup()
return uValue
#include "fivewin.ch"
FUNCTION Send_SMS(cURL)
cPageContent := wfReadUrl(cUrl)
RETURN cPageContent
*****************************************************************************
*** FUNCTION wfReadUrl(cUrl) Core Function to Post the cUrl to Internet ***
*****************************************************************************
FUNCTION wfReadUrl(cUrl)
LOCAL cPageContent := "Error: " + cUrl + " not found or timed out."
LOCAL oConn, oHttp
TRY
oHttp := oHttp := TOleAuto():New('WinHttp.WinHttpRequest.5.1')
oHttp:Open("PUT", cUrl, .F.)
oHttp:Send("Post Data")
cPageContent := oHttp:ResponseText
oHttp := nil
IF FILE("http.log")
ERASE http.log
ENDIF
CATCH
TRY
oHttp := TOleAuto():New('Msxml2.XMLHTTP.6.0')
oHttp:Open("GET", cUrl, .F.)
oHttp:Send("Post Data")
cPageContent := oHttp:ResponseText
oHttp := nil
IF FILE("http.log")
ERASE http.log
ENDIF
CATCH
TRY
oHttp := CreateObject("MSXML2.ServerXmlHttp")
IF Hb_IsObject(oHttp)
oHttp:Open("GET",cUrl,.F.)
oHttp:Send()
cPageContent := oHttp:ResponseText
ENDIF
CATCH
cPageContent := "Error opening the Url"
END
END
END
RETURN cPageContent
My Example:
cUrl := "https://sendpk.com/api/sms.php?api_key=923289536375-280edb13-b5f6-43e6-8b3c-45420519ce9c&sender=BrandName&mobile=Recipient&message=TextSMS"
Once the parameters are passed to the function, the SMS does not get sent. Probably due to the recipient number. The BrandName and TextSMS are Recipient are all character variables passed as parameters. Whereas I think the number must not be in quotes, I used macros but did not work.
Any other method to make the cURL to fulfill the API
Thnx in advance....
*****************************************************************************
*** FUNCTION wfReadUrl(cUrl) Core Function to Post the cUrl to Internet ***
*****************************************************************************
FUNCTION wfReadUrl(cUrl)
LOCAL cPageContent := "Error: " + cUrl + " not found or timed out."
LOCAL oConn, oHttp
TRY
oHttp := oHttp := TOleAuto():New('WinHttp.WinHttpRequest.5.1')
oHttp:Open("PUT", cUrl, .F.)
oHttp:Send("Post Data")
cPageContent := oHttp:ResponseText
oHttp := nil
IF FILE("http.log")
ERASE http.log
ENDIF
CATCH
cPageContent := "Failed calling - 'WinHttp.WinHttpRequest.5.1'"
END
TRY
oHttp := TOleAuto():New('Msxml2.XMLHTTP.6.0')
oHttp:Open("GET", cUrl, .F.)
oHttp:Send("Post Data")
cPageContent := oHttp:ResponseText
oHttp := nil
IF FILE("http.log")
ERASE http.log
ENDIF
CATCH
cPageContent := "Failed calling - 'Msxml2.XMLHTTP.6.0'"
END
TRY
oHttp := CreateObject('MSXML2.ServerXmlHttp')
IF Hb_IsObject(oHttp)
oHttp:Open("GET",cUrl,.F.)
oHttp:Send()
cPageContent := oHttp:ResponseText
ENDIF
CATCH
cPageContent := "Failed calling - 'MSXML2.ServerXmlHttp'"
END
MsgInfo(cPageContent)
RETURN cPageContent
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], nageswaragunupudi and 63 guests