MyBB Community Forums

Full Version: cURL function issue, when used in MyBB?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello there,

I currently have this function:
function grabData($url){
	curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 2);
	$output = curl_exec($ch);
	curl_close($ch);
	if ($output == null){
		$output = "An error occurred";
	}
	return $output;
}

I know this function works, when used in a normal webpage, to retrieve the contents of a JSON file from an API. But when I call this function in my MyBB plugin, it always returns "An error occured". I have tried changing the timeout, up to 25, but that has no effect. The function seems to be skipping the request to the API because there is no difference in wait time at all, from the time I start the function to the time I get an error. Does MyBB not allow normal functions like this? Is there some way to achieve the same thing in MyBB?

Any help would be greatly appreciated.

Don't worry, we solved this issue. It was an issue with https.
thanks anyway.