Author Topic: WSCurl SimpleHTTP  (Read 3872 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 95
    • View Profile
WSCurl SimpleHTTP
« on: September 22, 2016, 12:34:11 PM »
Purpose:
Execute a simple URL and retrieve metadata information using WSCurl.

Liquid UI Code:

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

// Function to execute a simple URL and retrieve information
function simple_http() {   
   var wsCurl = new Curl();
      
   /* Build the URL to make a call*/
   var completeURL = "http://www.guixt.com/";

   /* Note this use is for calls made to www.guixt.com which returns us the JSON object in string*/
    wsCurl.setopt(Curl.CURLOPT_URL, completeURL);
   
   /* You can check the return code to avoid error data string which can be found from "wsCurl.error"
    * return value 0 means success*/

   var response = wsCurl.exec();
   var error = wsCurl.error;
   
   z_tmp = response.substring(0,2000);
   copytext({"fromstring":"z_tmp", "totext":"z_text"});
   
   /* Close the http connection for the URL fetch*/
   wsCurl.close();
   
   /* Remove any reference for Garbage Collection*/
   wsCurl= NULL;
}

// User Interface
clearscreen();
pushbutton([1,0], 'WWW.GUIXT.COM', '?',{"size":[1,15], "process":simple_http});
text([3,1], "http Details below - ");
textbox([4,1], [24, 100],{"name":"z_text"});


See attachments for code samples!
« Last Edit: September 22, 2016, 01:36:53 PM by Benjamin Dasari »