Skip to content

Instantly share code, notes, and snippets.

@amolpednekar
Created March 5, 2018 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amolpednekar/ef3548aa4c28e7fed77eba95ead2f43b to your computer and use it in GitHub Desktop.
Save amolpednekar/ef3548aa4c28e7fed77eba95ead2f43b to your computer and use it in GitHub Desktop.
<?php
ini_set('max_execution_time', 0);
$host="10.xxx.x.xx";
$port="999";
$user="username";
$password="password";
$url='http://'.$host.':'.$port.'/';
$strUserPass64= base64_encode($user.':'.$password);
$method="publish";
$params=array("mystream","key9991","AB");
$payload=json_encode(array(
'method' => $method,
'params' => $params,
));
$header='Content-Type: application/json'."\r\n".
'Content-Length: '.strlen($payload)."\r\n".
'Connection: close'."\r\n".
'Authorization: Basic '.$strUserPass64."\r\n";
$options = array(
'http' => array(
'header' => $header,
'method' => 'POST',
'content' => $payload
)
);
$context = stream_context_create($options);
for($i=0;$i<20;$i++){
echo "req start";
$response = file_get_contents($url, false, $context);
echo $response;
echo "req end";
echo "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment