Hi, I am doing a simple GET request using curl but I can't make it work. I have curl installed and I was able to do some POST/GET requests to other sites so I know it's working.
class TestsController extends ControllerBase{
public function curlAction{
$this->view->disable();
$this->response->setStatusCode(200,'OK');
$this->response->setJsonContent(['content' => 'success']);
$this->response->send();
}
public function sendAction(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://localhost/tests/curl");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
var_dump($output); //result is always false
}
}
The curl action works when I am using cli CURL and when using POSTMAN, but no luck when trying the send action. Am I missing something?
--EDIT--
When I try to output curl error it says couldn't connect to host.