Skip to content

Instantly share code, notes, and snippets.

@stevenchan
Created January 22, 2010 08:44
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 stevenchan/283629 to your computer and use it in GitHub Desktop.
Save stevenchan/283629 to your computer and use it in GitHub Desktop.
<?php
if(!isset($_POST['message'])){ exit(); }
$host = "127.0.0.1:8001";
$channel = "chat";
$message = '"'.$_POST['message'].'"';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$host/channels/$channel");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: '.strlen($message)));
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment