Skip to content

Instantly share code, notes, and snippets.

@mookofe
Last active December 7, 2018 07:52
Show Gist options
  • Save mookofe/d3ae82abb29218343679e713f0b60bcd to your computer and use it in GitHub Desktop.
Save mookofe/d3ae82abb29218343679e713f0b60bcd to your computer and use it in GitHub Desktop.
Github Webhooks
<?php
namespace App\Http\Controllers;
use Route;
use Illuminate\Http\Request;
class GitHubController extends Controller
{
/**
* Update ticket status depending on github action
*
* @param Request $request Basic Request
*
* @return void
*/
public function gitHubUpdate(Request $request)
{
$content = $request->getContent();
$status = $request->get('action');
$pullRequest = $request->get('pull_request');
$pullBody = $pullRequest['body'];
}
}
@Gijera
Copy link

Gijera commented Nov 27, 2017

Hi, Mookofe! I am used laravel 5.1. when I add webhook in GitHub, url is http://mywebsite/api/github. but it always said response 500.this is html response headers:
Cache-Control: no-cache, private
Connection: keep-alive
Content-Length: 13912
Content-Type: text/html
date: Mon, 27 Nov 2017 04:55:03 GMT
Server: nginx/1.4.6 (Ubuntu)
Transfer-Encoding: chunked
X-Powered-By: PHP/5.5.9-1ubuntu4.22

ok, I get it. because I forgot add $except = "api/github" in VerifyCsrfToken Middleware. Thank you!

@insign
Copy link

insign commented Mar 14, 2018

@Gijera, since you are using api routes, and it is stateless, you should not using CSRF middleware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment