private function KalturaClientBase::doPostRequest in Kaltura 6.2
* HTTP stream context request * *
Parameters
string $url: * @param array $params * @return array of result and error
1 call to KalturaClientBase::doPostRequest()
- KalturaClientBase::doHttpRequest in kaltura_client/
KalturaClientBase.php - * Send http request by using curl (if available) or php stream_context * *
File
- kaltura_client/
KalturaClientBase.php, line 222
Class
Code
private function doPostRequest($url, $params = array(), $files = array()) {
if (count($files) > 0) {
throw new Exception("Uploading files is not supported with stream context http request, please use curl");
}
$formattedData = http_build_query($params, "", "&");
$params = array(
'http' => array(
"method" => "POST",
"Accept-language: en\r\n" . "Content-type: application/x-www-form-urlencoded\r\n",
"content" => $formattedData,
),
);
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
$phpErrorMsg = "";
throw new Exception("Problem with {$url}, {$phpErrorMsg}");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from {$url}, {$phpErrorMsg}");
}
return array(
$response,
'',
);
}