Author Topic: WSCurl Send SMS  (Read 4806 times)

Vivek Indripala

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 8
    • View Profile
WSCurl Send SMS
« on: February 26, 2019, 07:52:28 AM »
Purpose:
Send sms using WSCurl from SAP.

Liquid UI Code:

//SAPLSMTR_NAVIGATION.E0100.sjs
load('wscurl.dll');


//User Interface

clearscreen();
inputfield([6,3],"Message",[6,18],{"name":"z_message_info","size":50});
inputfield([3,3],"Phone number",[3,18],{"name":"to_number","size":23});
pushbutton([12,17], "Send sms",{ "process":send_sms, "using":{"z_message_info":z_message_info,"to_number":to_number}});



function send_sms(param)
{
   
   /*Copy the meesage from param object to variable z_message */
   var z_message = param.z_message_info;         
   
   /*Copy the source number from param object to variable mobile */
   var mobile = param.to_number;   
   
   /*Initialize the Curl object for making the call*/
   var wsCurl = new Curl();
   
   /* base url is the fixed string to concat our details and send message */
   var baseURL = "http://www.bhashsms.com/api/sendmsg.php?";            
   
   
   /* user credentials which needed to be concated to baseurl */
   var user= "user=tfhgld&pass=donate&sender=MPAYAD&phone=";
   
   
   /*String &text= is used in the URL to concat message to it */
   var tex = "&text=";      
   
   /* The messsage format from the input field is text format we convert it to string format using copytext */
   copytext({"fromtext":"z_message", "tostring":"z_str", "line":1}); 
   
   /* All the empty spaces in message body is replaced %20 to maintain the same user given space gap between words*/
   var message = z_str.replace(/ /g,'%20');      
   
   /* To provide priority and type for the message */
   var misc = "&priority=ndnd&stype=normal";
   
   /*Complete Url is stored in variable completeURL after concatenating necessary details*/
   var completeURL = baseURL + user + mobile + tex + message + misc ;
   
        /*Stored the complete URL in variable to g_url to know the URL format in Cornelius window*/
    set("V[g_URL]",completeURL);   
   
   
        /* This is the name of the proxy, if a proxy is used. the second parameter should be a string. */
   wsCurl.setopt(Curl.CURLOPT_URL, completeURL);         
   
   /* The exec API enables you to specify a response to the query you are making. The response can be either JSON or HTML */
   var response = wsCurl.exec();   
   
   
   /* Close the http connection for the URL fetch*/
   wsCurl.close();
   
   /*Remove any reference for Garbage Collection*/
   wsCurl= NULL;
   
   /* Condition to check the message delivery status */
   if(!isBlank(response))
   {
     return("S: message sent");
   }
   else
   {
     return("E:message not sent");
   }
          
}


/* Function to check if the string value is blank  */
function isBlank(jvar){
    if (jvar==void 0 || jvar=="" || jvar==null) {
        return true;
    }
    else {
        return false;
    }
}