Controller with external API only works on localhost

I’ve created a Site controller to use with the Eventbrite API. It works great on my localhost. But it doesn’t not work live.

Here is my controller:

    <?php  return function ($site, $pages, $page) {
$workshops = [];
$token = 'XXXX';
$organizer = XXXX;
$eburl = 'https://www.eventbriteapi.com/v3/events/search/?token=' . $token . '&organizer.id=' . $organizer ;
$wurl = $eburl . '&subcategories=5999';
$wrequest = remote::request($wurl);
	if (!empty($wrequest->content)) {
	$workshops = json_decode($wrequest->content, true);
	$wid = $workshops['events'][0];
	if(empty($wid)){
		$wmessage = '<em>There are currently no workshops scheduled. Be sure to join our <a href="#">mailing list</a> for the latest news.</em>';
	}
} 
 return compact('workshops',  'wmessage');
 }; 

And here is my template:

<?php foreach($workshops['events'] as $workshop): ?>
 <li><a href="<?php echo $workshop['url'] ?>"></a> <?php echo $workshop['name']['text']</li>
<?php endforeach ?>	

There error I get when it’s on my remote server, is “Invalid argument supplied for foreach()”

I’m guessing that the endpoint[‘events’] is not being read. But can’t figure out why.

To try and debug this, remove the loop and replace with

dump($workshops);

and check what is gives you.

when I do any kind of dump, all I get is:
Array
(
)

When I do a dump on my localhost, I get the full array with all the data