From FreeSWITCH Wiki
Jump to: navigation, search

fetchUrl is used to fetch a document and store it in a variable.



var result = fetchUrl(<url>, [bufferSize]);
  • result - Will contain document info, or false if an error occurred during the fetching.
  • url - The complete url to the document.
  • bufferSize - Optional parameter that specifies size of the buffer, default size is 65535 bytes.

Error reasons

  • The url is incorrect.
  • The buffer is too small for the document.

Use through web proxy

If you have to use fetchUrl through a corporate web proxy you can set the environment variable http_proxy='http://proxy_username:proxy_password@proxy.ip.address:proxy.port' You can done this only if security is not a first concern for you (e.g. you are the only one using the freeswitch machine).


var result = fetchUrl("https://localhost/user/get/1");
if (result == false)
  console_log("Failed to get user");
  console_log("User doc: " + result);

See Also