setEndpointResponse

setEndpointResponse ( mixed responseValue , string _format ) : void

Normally the cloud endpoint simply returns a message that a request to run the script has been added.
With the option synchronous in the endpoint parameters, the call waits until the crawling script calls the setEndpointResponse function. From then on, the endpoint returns the response specified by this function.
Remember to set a generous timeout on the endpoint request based on the maximum time the script can take.

Example


// 1) The endpoint is called in synchronous mode : https://www.idia-tech.com/endpoint_script.php?pass=abababa&server_id=7link=LOCAL:-1&script_id=1234&synchronous=1
// 2) The endpoint request does not respond for the moment
// 3) This script is executed on the Cloud

response = [
"id_serveur": getCloudIdServer(),
"nb_task_on_cloud": count(getAllRunningScripts())
]
setEndpointResponse(response, "json")

// 4) The endpoint stops waiting and returns {"id_serveur":7,"nb_task_on_cloud":3}


See also

setSharedOnlineConfiguration

Parameters

responseValue

The value returned by the endpoint

_format (optional)

Response format:
  • "json" (default) : the responseValue will be printed json-encoded (used it for objects)
  • "text": the responseValue is simply printed