cUrl in controller
Content
Hi,
I'm trying to test some cUrl functionality. I'm using the code mentioned but I get:
There has been an error with your request.
However, accessing the controller directly, it runs fine. The reason I am testing cUrl is what I want to put it into the custom scripts section of a report so the function is run on a schedule.
I am using the exact same cUrl syntax for requests to the REST API without issue so why is it failing here?
Code Snippet
public function testcurlhere() { RNCPHP\ConnectAPI::getCurrentContext()->ApplicationContext = "Get Google Places API"; $url = "https://{SITE_NAME}.custhelp.com/cc/{CONTROLLER_NAME}/{FUNCTION_NAME}"; if (!function_exists("\curl_init")){ \load_curl(); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT,6000); curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE); $body = \curl_exec($ch); curl_close($ch); var_dump($body); }
Tagged:
1