Adding support for Github Content-Type: application/json web hooks.

See #668
This commit is contained in:
Dan Cryer 2014-12-01 15:48:22 +00:00
parent b2a6ea38ee
commit 084203f0cf

View file

@ -52,11 +52,23 @@ class WebhookController extends \PHPCI\Controller
*/
public function bitbucket($project)
{
$payload = json_decode($this->getParam('payload'), true);
switch ($_SERVER['CONTENT_TYPE']) {
case 'application/json':
$payload = json_decode(file_get_contents('php://input'), true);
break;
case 'application/x-www-form-urlencoded':
$payload = json_decode($this->getParam('payload'), true);
break;
default:
header('HTTP/1.1 400 Bad Request');
die('Request content type not supported');
}
foreach ($payload['commits'] as $commit) {
try {
$email = $commit['raw_author'];
$email = substr($email, 0, strpos($email, '>'));
$email = substr($email, strpos($email, '<') + 1);