smalot/ bitbucket-webhook
处理webhook回调的Bitbucket API。
v0.2
2016-01-05 10:11 UTC
Requires
- php: >=5.3.0
- symfony/event-dispatcher: >=2.3
- symfony/http-foundation: >=2.3
This package is not auto-updated.
Last update: 2024-09-14 18:36:56 UTC
README
需求
- PHP 5.3+
- symfony/http-foundation >= 2.3
- symfony/event-dispatcher >= 2.3
安装
Composer
首先需要使用composer
下载此库。
composer require smalot/bitbucket-webhook
前往GetComposer.org安装Composer到您的环境中。
示例
从头开始
<?php require_once 'vendor/autoload.php'; $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals(); $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); // Todo: add listener to event dispatcher. $listener = ... $dispatcher->addListener(\Smalot\Bitbucket\Webhook\Events::WEBHOOK_REQUEST, $listener); $webhook = new \Smalot\Bitbucket\Webhook\Webhook($dispatcher); $event = $webhook->parseRequest($request);
使用Symfony在控制器中
<?php namespace AppBundle\Controller; use Smalot\Bitbucket\Webhook\Webhook; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class BitbucketController extends Controller { public function webhookAction(Request $request) { $dispatcher = $this->get('event_dispatcher'); $webhook = new Webhook($dispatcher); $event = $webhook->parseRequest($request); return Response('ok'); } }
不要忘记事先注册任何事件监听器。
文档
远程API
https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html
安全性
Bitbucket白名单IP范围
131.103.20.160/27
165.254.145.0/26
104.192.143.0/24
````
## Events
https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html