I tried cURL, file_get_contents, readfile but everything returns null, when I debug with broadcastMessage(), it doesnt send anything, and in the console it says " ". How can I get contents from a URL then? cURL; PHP: /* gets the data from a URL */public function get_data($url) {$ch = curl_init();$timeout = 5;curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$data = curl_exec($ch);curl_close($ch);return $data;}
i think that looks right. take a look at this: http://docs.pocketmine.net/dc/d1a/c..._utils.html#a3e2f80e894282e43c202315a340ea7f9
Yeah that's right, $timeout is how long it waits for a response before giving up and returning false.
Technically that is correct. However, the use of Utils::getURL() in the main thread is discouraged, apart from use in onEnable() and onDisable(). The reason is that Utils::getURL() blocks the thread, since it will not run the next line of code until it received a result. Unless this is something from localhost, this usually takes much more than 0.05 second, which is the length of one tick. Any code that takes more than one tick and can be done on other threads should be done on other threads.