Zend certified PHP/Magento developer

How to call a 3rd party API from a controller? Magento 2

I built a custom module. Its admin tables with CRUD functionality. I am putting a new button on the grid via the Ui_component listing xml file. When this button gets clicked I want to call a 3rd party API to load data into the current table.

This is the code for the button:


            add
            refresh
            primary
            */*/refreshAction
        

The refreshAction controller is where I need help with the code to make the API call. For now I just want to echo out the response, once I get the API call to return a successful response I will deal with actually saving the data to the table.
The code I have now that’s returning a 500 internal server error looks like this:

public function execute()
{
 $this->_curl->get('https://online.jil.com/api/index.aspx?action=GetAllDIDs');
    $response = $this->_curl->getBody();
    echo $response;
}