Use curl for getDataFromHTTP utility function
parent
8231fbb08c
commit
939f600b3f
|
@ -42,17 +42,20 @@ class Util
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDataFromHTTP($url, $content = "", $requestTyp = "application/text")
|
public static function getDataFromHTTP($url, $content = "", $requestType = "application/text")
|
||||||
{
|
{
|
||||||
try {
|
$curl = curl_init($url);
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
|
||||||
if ($content != "") {
|
if ($content != "") {
|
||||||
return file_get_contents($url, true, stream_context_create(array('http' => array('header' => 'Content-type: '.$requestTyp, 'method' => 'POST', 'timeout' => 0.5, 'content' => $content))));
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
} else {
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
|
||||||
return file_get_contents($url);
|
curl_setopt($curl, CURLOPT_USERAGENT, 'mcp/0.0.1');
|
||||||
}
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
} catch (Exception $e) {
|
'Content-Type' => $requestType
|
||||||
echo "(HTTP REQUEST) error while conntect to remote server. : ".$url;
|
]);
|
||||||
}
|
}
|
||||||
|
return curl_exec($curl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sendInworldIM($fromUUID, $toUUID, $fromName, $targetURL, $text)
|
public static function sendInworldIM($fromUUID, $toUUID, $fromName, $targetURL, $text)
|
||||||
|
|
Loading…
Reference in New Issue