正在显示
9 个修改的文件
包含
162 行增加
和
18 行删除
| @@ -111,10 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -111,10 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 111 | * @param :platforms: "facebook", "fbg", "twitter", | 111 | * @param :platforms: "facebook", "fbg", "twitter", |
| 112 | * "linkedin", "instagram","youtube", "reddit" ,"telegram"" | 112 | * "linkedin", "instagram","youtube", "reddit" ,"telegram"" |
| 113 | */ | 113 | */ |
| 114 | - public function post_send_msg($param){ | 114 | + public function post_send_msg($param,$api_key){ |
| 115 | //平台参数处理 | 115 | //平台参数处理 |
| 116 | $this->headers['Accept-Encoding'] = 'gzip'; | 116 | $this->headers['Accept-Encoding'] = 'gzip'; |
| 117 | - $this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key']; | 117 | + $this->headers['Authorization'] = $this->headers['Authorization'].$api_key; |
| 118 | $url = $this->path.'/api/post'; | 118 | $url = $this->path.'/api/post'; |
| 119 | return $this->http_click('posts',$url,$param,$this->headers); | 119 | return $this->http_click('posts',$url,$param,$this->headers); |
| 120 | } | 120 | } |
| @@ -2,8 +2,12 @@ | @@ -2,8 +2,12 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside\AyrShare; | 3 | namespace App\Http\Controllers\Bside\AyrShare; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Helper\AyrShare as AyrShareHelper; | ||
| 5 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 6 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; | 8 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; |
| 9 | +use App\Http\Logic\Bside\AyrShare\AyrShareLogic; | ||
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 7 | 11 | ||
| 8 | /** | 12 | /** |
| 9 | * @name:社交发布 | 13 | * @name:社交发布 |
| @@ -16,10 +20,25 @@ class AyrReleaseController extends BaseController | @@ -16,10 +20,25 @@ class AyrReleaseController extends BaseController | ||
| 16 | * @method :post | 20 | * @method :post |
| 17 | * @time :2023/5/9 9:36 | 21 | * @time :2023/5/9 9:36 |
| 18 | */ | 22 | */ |
| 19 | - public function send_post(AyrReleaseLogic $ayrReleaseLogic){ | ||
| 20 | - //保存数据库 | ||
| 21 | - $ayrReleaseLogic->release_add(); | 23 | + public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){ |
| 24 | + DB::beginTransaction(); | ||
| 25 | + try { | ||
| 26 | + //获取发送账号详情 | ||
| 27 | + $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 28 | + $param = [ | ||
| 29 | + 'post'=>$this->param['content'], | ||
| 30 | + 'platforms'=>$this->param['platforms'], | ||
| 31 | + 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 | ||
| 32 | + ]; | ||
| 33 | + //发送请求注册社交用户 | ||
| 34 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 35 | + $res = $ayrShareHelper->post_send_msg($param,$share_info['profile_key']); | ||
| 36 | + $this->response('success',Code::SUCCESS,$res); | ||
| 37 | + //保存数据库 | ||
| 38 | + $ayrReleaseLogic->release_add(); | ||
| 39 | + }catch (\Exception $e){ | ||
| 22 | 40 | ||
| 41 | + } | ||
| 23 | } | 42 | } |
| 24 | 43 | ||
| 25 | } | 44 | } |
| @@ -21,14 +21,26 @@ class AyrShareController extends BaseController | @@ -21,14 +21,26 @@ class AyrShareController extends BaseController | ||
| 21 | */ | 21 | */ |
| 22 | public function lists(AyrShareModel $ayrShareModel){ | 22 | public function lists(AyrShareModel $ayrShareModel){ |
| 23 | $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']); | 23 | $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']); |
| 24 | - $ayrShareHelper = new AyrShareHelper(); | ||
| 25 | - foreach ($lists['list'] as $k=>$v){ | ||
| 26 | - $lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']); | ||
| 27 | - } | ||
| 28 | $this->response('列表',Code::SUCCESS,$lists); | 24 | $this->response('列表',Code::SUCCESS,$lists); |
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | /** | 27 | /** |
| 28 | + * @name :(定时更新)save_account | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/5/9 14:39 | ||
| 32 | + */ | ||
| 33 | + public function save_account(AyrShareLogic $ayrShareLogic){ | ||
| 34 | + $info = $ayrShareLogic->ayr_share_info(); | ||
| 35 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 36 | + $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']); | ||
| 37 | + if(isset($share_info['activeSocialAccounts'])){ | ||
| 38 | + $str = json_encode($share_info['activeSocialAccounts']); | ||
| 39 | + $ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]); | ||
| 40 | + } | ||
| 41 | + $this->response('success'); | ||
| 42 | + } | ||
| 43 | + /** | ||
| 32 | * @name :(创建ayr_share账户)create_account | 44 | * @name :(创建ayr_share账户)create_account |
| 33 | * @author :lyh | 45 | * @author :lyh |
| 34 | * @method :post | 46 | * @method :post |
| @@ -151,7 +151,7 @@ class BaseController extends Controller | @@ -151,7 +151,7 @@ class BaseController extends Controller | ||
| 151 | * @author :liyuhang | 151 | * @author :liyuhang |
| 152 | * @method | 152 | * @method |
| 153 | */ | 153 | */ |
| 154 | - protected function _extents($data) { | 154 | + public function _extents($data) { |
| 155 | 155 | ||
| 156 | if (empty($data) || !is_array($data)) { | 156 | if (empty($data) || !is_array($data)) { |
| 157 | return empty($data) ? is_array($data) ? [] : '' : $data; | 157 | return empty($data) ? is_array($data) ? [] : '' : $data; |
| @@ -173,11 +173,12 @@ class ImageController | @@ -173,11 +173,12 @@ class ImageController | ||
| 173 | return $this->response($file->getError(), Code::USER_ERROR); | 173 | return $this->response($file->getError(), Code::USER_ERROR); |
| 174 | } | 174 | } |
| 175 | $save_data[] = [ | 175 | $save_data[] = [ |
| 176 | - 'path' => $url.'/'.$res->getClientOriginalName(), | 176 | + 'path' => $url.'/'.$file->getClientOriginalName(), |
| 177 | 'created_at' => date('Y-m-d H:i:s',time()), | 177 | 'created_at' => date('Y-m-d H:i:s',time()), |
| 178 | + 'updated_at'=>date('Y-m-d H:i:s',time()), | ||
| 178 | 'size' => $res->getSize(), | 179 | 'size' => $res->getSize(), |
| 179 | 'hash' => $hash, | 180 | 'hash' => $hash, |
| 180 | - 'type'=>$files->getClientOriginalExtension(), | 181 | + 'type'=>$file->getClientOriginalExtension(), |
| 181 | ]; | 182 | ]; |
| 182 | $data[] = $hash; | 183 | $data[] = $hash; |
| 183 | } | 184 | } |
| @@ -36,30 +36,111 @@ class AyrReleaseLogic extends BaseLogic | @@ -36,30 +36,111 @@ class AyrReleaseLogic extends BaseLogic | ||
| 36 | * @method :post | 36 | * @method :post |
| 37 | * @time :2023/5/9 10:02 | 37 | * @time :2023/5/9 10:02 |
| 38 | */ | 38 | */ |
| 39 | - public function ayr_release_add(){ | 39 | + public function ayr_release_add($param){ |
| 40 | $param = [ | 40 | $param = [ |
| 41 | 'post'=>$this->param['content'], | 41 | 'post'=>$this->param['content'], |
| 42 | - 'platforms'=>$this->param['platforms'] | 42 | + 'platforms'=>$this->param['platforms'], |
| 43 | + 'mediaUrls'=>$this->param['mediaUrls'], | ||
| 43 | ]; | 44 | ]; |
| 45 | + return $this->success($param); | ||
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | /** | 48 | /** |
| 49 | + * @name :(发布到推特)post_twitter | ||
| 50 | + * @author :lyh | ||
| 51 | + * @method :post | ||
| 52 | + * @time :2023/5/9 13:42 | ||
| 53 | + */ | ||
| 54 | + public function post_twitter($param){ | ||
| 55 | + $param['post'] = '描述'; | ||
| 56 | + $param['platforms'] = ['twitter']; | ||
| 57 | + $param['twitterOptions'] = [ | ||
| 58 | + 'thread'=> true, | ||
| 59 | + 'threadNumber'=> true, | ||
| 60 | + 'mediaUrls'=>[ | ||
| 61 | + //图片地址 | ||
| 62 | + ], | ||
| 63 | + ]; | ||
| 64 | + return $this->success($param); | ||
| 65 | + } | ||
| 66 | + /** | ||
| 47 | * @name :(发布到youtube)post_facebook | 67 | * @name :(发布到youtube)post_facebook |
| 48 | * @author :lyh | 68 | * @author :lyh |
| 49 | * @method :post | 69 | * @method :post |
| 50 | * @time :2023/5/9 10:05 | 70 | * @time :2023/5/9 10:05 |
| 51 | */ | 71 | */ |
| 52 | public function post_facebook(){ | 72 | public function post_facebook(){ |
| 53 | - return $this->success(); | 73 | + $param['post'] = '视频描述'; |
| 74 | + $param['platforms'] = ['facebook']; | ||
| 75 | + $param['faceBookOptions'] = [ | ||
| 76 | + 'reels'=> true, | ||
| 77 | + 'title'=>'Super title for the Reel' | ||
| 78 | + ]; | ||
| 79 | + return $this->success($param); | ||
| 54 | } | 80 | } |
| 55 | 81 | ||
| 56 | /** | 82 | /** |
| 57 | - * @name :(发布到youtube)post_youtube | 83 | + * @name :(发布到fbg,)post_youtube |
| 58 | * @author :lyh | 84 | * @author :lyh |
| 59 | * @method :post | 85 | * @method :post |
| 60 | * @time :2023/5/9 10:22 | 86 | * @time :2023/5/9 10:22 |
| 87 | + * @TODO::只能发布一张图片和一张视频 | ||
| 61 | */ | 88 | */ |
| 62 | - public function post_youtube(){ | 89 | + public function post_gmb(){ |
| 90 | + $param['post'] = '描述'; | ||
| 91 | + $param['platforms'] = ['gmb']; | ||
| 92 | + $param['mediaUrls'] = [];//图片链接 | ||
| 93 | + $param['gmbOptions'] = [ | ||
| 94 | + //视屏设置 | ||
| 95 | + 'isPhotoVideo' => true, | ||
| 96 | + 'category'=> 'cate',//分类 | ||
| 97 | + ]; | ||
| 98 | + return $this->success($param); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * @name :(发布到instagram)post_google | ||
| 103 | + * @author :lyh | ||
| 104 | + * @method :post | ||
| 105 | + * @time :2023/5/9 11:54 | ||
| 106 | + */ | ||
| 107 | + public function post_instagram(){ | ||
| 108 | + $param['post'] = '视频描述'; | ||
| 109 | + $param['platforms'] = ['instagram']; | ||
| 110 | + $param['faceBookOptions'] = [ | ||
| 111 | + 'reels'=> true, | ||
| 112 | + 'title'=>'Super title for the Reel' | ||
| 113 | + ]; | ||
| 63 | return $this->success(); | 114 | return $this->success(); |
| 64 | } | 115 | } |
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * @name :(领英)post_linkedin | ||
| 119 | + * @author :lyh | ||
| 120 | + * @method :post | ||
| 121 | + * @time :2023/5/9 11:56 | ||
| 122 | + */ | ||
| 123 | + public function post_linkedin(){ | ||
| 124 | + return $this->success(); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @name :(红迪网)post_reddit | ||
| 129 | + * @author :lyh | ||
| 130 | + * @method :post | ||
| 131 | + * @time :2023/5/9 13:40 | ||
| 132 | + */ | ||
| 133 | + public function post_reddit(){ | ||
| 134 | + return $this->success(); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * @name :(抖音)post_tiktok | ||
| 139 | + * @author :lyh | ||
| 140 | + * @method :post | ||
| 141 | + * @time :2023/5/9 13:44 | ||
| 142 | + */ | ||
| 143 | + public function post_tiktok(){ | ||
| 144 | + | ||
| 145 | + } | ||
| 65 | } | 146 | } |
| @@ -56,6 +56,19 @@ class AyrShareLogic extends BaseLogic | @@ -56,6 +56,19 @@ class AyrShareLogic extends BaseLogic | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | + * @name :(更新)ayr_share_edit | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/5/9 14:44 | ||
| 63 | + */ | ||
| 64 | + public function ayr_share_edit($param){ | ||
| 65 | + $rs = $this->model->edit($param,['id'=>$this->param['id']]); | ||
| 66 | + if($rs === false){ | ||
| 67 | + $this->fail('error'); | ||
| 68 | + } | ||
| 69 | + return $this->success(); | ||
| 70 | + } | ||
| 71 | + /** | ||
| 59 | * @name :(删除ayr数据并同步删除) | 72 | * @name :(删除ayr数据并同步删除) |
| 60 | * @author :lyh | 73 | * @author :lyh |
| 61 | * @method :post | 74 | * @method :post |
| @@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest | @@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest | ||
| 15 | { | 15 | { |
| 16 | return true; | 16 | return true; |
| 17 | } | 17 | } |
| 18 | + /** | ||
| 19 | + * Get the validation rules that apply to the request. | ||
| 20 | + * | ||
| 21 | + * @return array | ||
| 22 | + */ | ||
| 23 | + public function rules() | ||
| 24 | + { | ||
| 25 | + return [ | ||
| 26 | + 'name'=>'required||unique:gl_ayr_share,name', | ||
| 27 | + ]; | ||
| 28 | + } | ||
| 18 | 29 | ||
| 30 | + public function messages() | ||
| 31 | + { | ||
| 32 | + return [ | ||
| 33 | + 'name.required'=>'请填写名称', | ||
| 34 | + ]; | ||
| 35 | + } | ||
| 19 | } | 36 | } |
| @@ -211,7 +211,8 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -211,7 +211,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 211 | 211 | ||
| 212 | //社交绑定 | 212 | //社交绑定 |
| 213 | Route::prefix('ayr')->group(function () { | 213 | Route::prefix('ayr')->group(function () { |
| 214 | - Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists'); | 214 | + Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists'); |
| 215 | + Route::any('/save', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'save_account'])->name('ayr_save_account'); | ||
| 215 | Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); | 216 | Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); |
| 216 | Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account'); | 217 | Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account'); |
| 217 | Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account'); | 218 | Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account'); |
-
请 注册 或 登录 后发表评论