diff --git a/PHPCI/Controller/WebhookController.php b/PHPCI/Controller/WebhookController.php index 4884edf9..fb3a76d7 100644 --- a/PHPCI/Controller/WebhookController.php +++ b/PHPCI/Controller/WebhookController.php @@ -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);