Skip to main content

Run

Click here to expand Table of Contents

Description

Performs a CURL operation (eg. GET, POST).

Synopsis

run(method, url, request_data, callback, callback_arg, credentials, timeout, content-type)
  • method - any CURL supported method (eg. get, post)
  • url - any CURL supported URL
  • request_data - URL-encoded request data
  • callback - user callback function
  • callback_arg - argument passed to user callback
  • credentials - to be used by CURL, in user:password format
  • timeout - curl timeout in seconds
  • content-type - http header content-type

Example

Note: callback will only fire if the target url returns a non-empty string.

use("CURL");

function my_callback(string, arg)
{
console_log("info", string);
return true;
}

if (session.ready()) {
session.answer();

var curl = new CURL();

curl.run("POST", "http://www.freeswitch.org/curltest/", "foo=bar&this=has+spaces+in+it", my_callback, "my arg\n", "user:s3cr3tpw");

session.hangup();
}

See Also