PHP code example of yansongda / git-notify
1. Go to this page and download the library: Download yansongda/git-notify library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yansongda / git-notify example snippets
fy = new Yansongda\GitNotify\GitNotify();
// 可选。gitee 可以设置 webhook 密码,防止 URL 被恶意请求
// $notify->from->password = '123456';
// 可选。可以随意设置发送模板与格式。这里用到闭包。
// $from 为 git 服务。
/* $notify->destination->setTemplate(function ($from) {
$data['msgtype'] = 'hahaha';
$data['text']['content'] = "姓名:" . $from->user_name .
"\n\before:" . $from->before .
"\n\nafter:" . $from->after .
"\n\n推送时间:" . date('Y-m-d H:i:s');
return $data;
});*/
$notify->destination->gateway = 'https://oapi.dingtalk.com/robot/send?access_token=36c01ca8552fa8f9f6xxxxx';
$response = $notify->destination->apply();
$result = $response->getBody()->getContents();