#!/usr/bin/env php
<?php
/**
 * https://api.slack.com/incoming-webhooks
 * https://my.slack.com/services/new/incoming-webhook/
 */
$url = 'https://hooks.slack.com/services/foo';
$payload = array(
    'text' => file_get_contents('php://stdin')
);
$context = stream_context_create(
    array(
        'http' => array(
            'method'  => 'POST',
            'header'  => 'Content-Type: application/json',
            'content' => json_encode($payload)
        )
    )
);
$response = file_get_contents($url, false, $context);
echo $response . "\n";
?>
