31 lines
689 B
PHP
31 lines
689 B
PHP
<?php
|
|
|
|
namespace app\common\service;
|
|
|
|
use support\Log;
|
|
use Webman\Push\Api;
|
|
|
|
class PushService
|
|
{
|
|
|
|
/**
|
|
* 推送消息
|
|
* @param $subscription 订阅
|
|
* @param $uid 用户id
|
|
* @param $content 消息内容
|
|
*/
|
|
public static function push($subscription, $uid, $content)
|
|
{
|
|
Log::info('PushService::push', [$subscription, $uid, $content]);
|
|
$api = new Api(
|
|
getenv('PUSH_URL'),
|
|
config('plugin.webman.push.app.app_key'),
|
|
config('plugin.webman.push.app.app_secret')
|
|
);
|
|
$api->trigger($subscription, 'message', [
|
|
'from_uid' => $uid,
|
|
'content' => $content
|
|
]);
|
|
}
|
|
}
|