飞书消息

This commit is contained in:
2025-03-22 20:08:01 +08:00
parent 97250ca23e
commit b6409a69ed
2 changed files with 27 additions and 11 deletions
+18 -9
View File
@@ -72,8 +72,14 @@ class FeishuController
public function auth(Request $request)
{
$param = $request->all();
$userId = $request->user['id'];
$config = User::where('id',$userId)->value('sign');
if(Util::isEmpty($config)){
return Util::fail(null,trans('sign_not_null'));
}
// 获取凭证
$certificate = config($this->config);
$certificate = config('feishu.'.$config);
// 飞书服务
$class = new \app\service\FeishuService($certificate['appId'], $certificate['appSecret'], $certificate['state']);
@@ -91,10 +97,11 @@ class FeishuController
}
Log::info('feishu user_info', ['res' => $rst]);
$state = explode(",", $param['state']);
$state = explode("_", $param['state']);
//$userId = $request->user['id'];
$userId = $state[2];
$userId = $state[1];
$user = FeishuUser::where('id', $userId)->first();
$user = FeishuUser::create();
//保存用户open_id
$user->user_id = $userId;
@@ -138,7 +145,8 @@ class FeishuController
// string(7) "success"
// }
return json($rst);
// return json($rst);
return Util::success($rst['data'], trans('success'));
} else {
//需要登录并且未提供token
if (!Util::isEmpty($request->user['id'])) {
@@ -161,11 +169,11 @@ class FeishuController
* @param $href 详情链接
* @return \support\Response
*/
public function send($receiveId,$title,$content,$href)
public static function send($config='xinyouhe',$receiveId='ou_e33bb3017ada6c4781398a68e55a4696',$title='ceshi',$content='测试',$href='http://219.157.255.213:8085/pages/index/mine')
{
Log::info('feishu send', ['receiveId' => $receiveId, 'title' => $title, 'content' => $content, 'href' => $href]);
// 获取凭证
$certificate = config($this->config);
$certificate = config('feishu.'.$config);
Log::info('feishu send', [$certificate,'config'=>$config,'receiveId' => $receiveId, 'title' => $title, 'content' => $content, 'href' => $href]);
// 飞书服务
$class = new \app\service\FeishuService($certificate['appId'], $certificate['appSecret'], $certificate['state']);
@@ -196,7 +204,7 @@ class FeishuController
}";
// 卡片 类型
/* $content = "{
/*$content = "{
\"config\":{
\"wide_screen_mode\":true
},
@@ -225,7 +233,8 @@ class FeishuController
}
}
}";*/
$msgType = 'interactive';
// $msgType = 'interactive';
$msgType = 'post'; //卡片消息:interactive,富文本消息:post
$receiveIdtype = 'open_id';
$result = $class->sendMessages($receiveId, $content, $msgType, $receiveIdtype);