AyrReleaseController.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace App\Http\Controllers\Bside\AyrShare;
use App\Enums\Common\Code;
use App\Helper\AyrShare as AyrShareHelper;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use Illuminate\Support\Facades\DB;
/**
* @name:社交发布
*/
class AyrReleaseController extends BaseController
{
/**
* @name :(获取当前用户已绑定的社交链接)info
* @author :lyh
* @method :post
* @time :2023/5/9 16:00
*/
public function info(AyrShareLogic $ayrShareLogic){
$info = $ayrShareLogic->ayr_share_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :(发布社交)send_post
* @author :lyh
* @method :post
* @time :2023/5/9 9:36
*/
public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
DB::beginTransaction();
try {
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
$data = [
'image'=>explode(',',$this->param['image']),
'file'=>explode(',',$this->param['file'])
];
//参数处理
$image_file = $this->_extents($data);
$this->param['mediaUrls'] = $image_file;
//统一生成链接
$param = [
'post'=>$this->param['content'],
'platforms'=>$this->param['platforms'],
'mediaUrls'=>$this->param['mediaUrls'],//参数处理
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_send_msg($param,$share_info['profile_key']);
$this->response('success',Code::SUCCESS,$res);
//保存数据库
$ayrReleaseLogic->release_add();
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->response('error',Code::USER_ERROR);
}
}
}