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);
|
||||||
if ($content != "") {
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
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_TIMEOUT, 1);
|
||||||
} else {
|
if ($content != "") {
|
||||||
return file_get_contents($url);
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
}
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
|
||||||
} catch (Exception $e) {
|
curl_setopt($curl, CURLOPT_USERAGENT, 'mcp/0.0.1');
|
||||||
echo "(HTTP REQUEST) error while conntect to remote server. : ".$url;
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
|
'Content-Type' => $requestType
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
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