function getUrl($url, $requestType = 'GET', $timeout = 30) { $curl = new curl(); $curl->curl($url); if ($requestType == "POST") { $postString = ""; foreach ($postArray as $postField => $postValue) { $postString .= "{$postField}=" . $postValue . "&"; } $postString .= "Enter="; $curl->setopt(CURLOPT_POST, 1); $curl->setopt(CURLOPT_POSTFIELDS, $postString); } $curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE); $curl->setopt(CURLOPT_USERAGENT, MAGPIE_USER_AGENT); $curl->setopt(CURLOPT_FOLLOWLOCATION, 1); // allow redirects $curl->setopt(CURLOPT_RETURNTRANSFER, 1); // return into a variable $curl->setopt(CURLOPT_TIMEOUT, $timeout); // times out after x seconds $result = $curl->exec(); // run the whole process $curl->close(); return $result; }