作者 lyh

gx

... ... @@ -111,10 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
* @param :platforms: "facebook", "fbg", "twitter",
* "linkedin", "instagram","youtube", "reddit" ,"telegram""
*/
public function post_send_msg($param){
public function post_send_msg($param,$api_key){
//平台参数处理
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/post';
return $this->http_click('posts',$url,$param,$this->headers);
}
... ...
... ... @@ -2,8 +2,12 @@
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 Illuminate\Support\Facades\DB;
/**
* @name:社交发布
... ... @@ -16,10 +20,25 @@ class AyrReleaseController extends BaseController
* @method :post
* @time :2023/5/9 9:36
*/
public function send_post(AyrReleaseLogic $ayrReleaseLogic){
//保存数据库
$ayrReleaseLogic->release_add();
public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
DB::beginTransaction();
try {
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
$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();
}catch (\Exception $e){
}
}
}
... ...
... ... @@ -21,14 +21,26 @@ class AyrShareController extends BaseController
*/
public function lists(AyrShareModel $ayrShareModel){
$lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
$ayrShareHelper = new AyrShareHelper();
foreach ($lists['list'] as $k=>$v){
$lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']);
}
$this->response('列表',Code::SUCCESS,$lists);
}
/**
* @name :(定时更新)save_account
* @author :lyh
* @method :post
* @time :2023/5/9 14:39
*/
public function save_account(AyrShareLogic $ayrShareLogic){
$info = $ayrShareLogic->ayr_share_info();
$ayrShareHelper = new AyrShareHelper();
$share_info = $ayrShareHelper->get_profiles_users($info['profile_key']);
if(isset($share_info['activeSocialAccounts'])){
$str = json_encode($share_info['activeSocialAccounts']);
$ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]);
}
$this->response('success');
}
/**
* @name :(创建ayr_share账户)create_account
* @author :lyh
* @method :post
... ...
... ... @@ -151,7 +151,7 @@ class BaseController extends Controller
* @author :liyuhang
* @method
*/
protected function _extents($data) {
public function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
... ...
... ... @@ -173,11 +173,12 @@ class ImageController
return $this->response($file->getError(), Code::USER_ERROR);
}
$save_data[] = [
'path' => $url.'/'.$res->getClientOriginalName(),
'path' => $url.'/'.$file->getClientOriginalName(),
'created_at' => date('Y-m-d H:i:s',time()),
'updated_at'=>date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
'type'=>$files->getClientOriginalExtension(),
'type'=>$file->getClientOriginalExtension(),
];
$data[] = $hash;
}
... ...
... ... @@ -36,30 +36,111 @@ class AyrReleaseLogic extends BaseLogic
* @method :post
* @time :2023/5/9 10:02
*/
public function ayr_release_add(){
public function ayr_release_add($param){
$param = [
'post'=>$this->param['content'],
'platforms'=>$this->param['platforms']
'platforms'=>$this->param['platforms'],
'mediaUrls'=>$this->param['mediaUrls'],
];
return $this->success($param);
}
/**
* @name :(发布到推特)post_twitter
* @author :lyh
* @method :post
* @time :2023/5/9 13:42
*/
public function post_twitter($param){
$param['post'] = '描述';
$param['platforms'] = ['twitter'];
$param['twitterOptions'] = [
'thread'=> true,
'threadNumber'=> true,
'mediaUrls'=>[
//图片地址
],
];
return $this->success($param);
}
/**
* @name :(发布到youtube)post_facebook
* @author :lyh
* @method :post
* @time :2023/5/9 10:05
*/
public function post_facebook(){
return $this->success();
$param['post'] = '视频描述';
$param['platforms'] = ['facebook'];
$param['faceBookOptions'] = [
'reels'=> true,
'title'=>'Super title for the Reel'
];
return $this->success($param);
}
/**
* @name :(发布到youtube)post_youtube
* @name :(发布到fbg,)post_youtube
* @author :lyh
* @method :post
* @time :2023/5/9 10:22
* @TODO::只能发布一张图片和一张视频
*/
public function post_youtube(){
public function post_gmb(){
$param['post'] = '描述';
$param['platforms'] = ['gmb'];
$param['mediaUrls'] = [];//图片链接
$param['gmbOptions'] = [
//视屏设置
'isPhotoVideo' => true,
'category'=> 'cate',//分类
];
return $this->success($param);
}
/**
* @name :(发布到instagram)post_google
* @author :lyh
* @method :post
* @time :2023/5/9 11:54
*/
public function post_instagram(){
$param['post'] = '视频描述';
$param['platforms'] = ['instagram'];
$param['faceBookOptions'] = [
'reels'=> true,
'title'=>'Super title for the Reel'
];
return $this->success();
}
/**
* @name :(领英)post_linkedin
* @author :lyh
* @method :post
* @time :2023/5/9 11:56
*/
public function post_linkedin(){
return $this->success();
}
/**
* @name :(红迪网)post_reddit
* @author :lyh
* @method :post
* @time :2023/5/9 13:40
*/
public function post_reddit(){
return $this->success();
}
/**
* @name :(抖音)post_tiktok
* @author :lyh
* @method :post
* @time :2023/5/9 13:44
*/
public function post_tiktok(){
}
}
... ...
... ... @@ -56,6 +56,19 @@ class AyrShareLogic extends BaseLogic
}
/**
* @name :(更新)ayr_share_edit
* @author :lyh
* @method :post
* @time :2023/5/9 14:44
*/
public function ayr_share_edit($param){
$rs = $this->model->edit($param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(删除ayr数据并同步删除)
* @author :lyh
* @method :post
... ...
... ... @@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name'=>'required||unique:gl_ayr_share,name',
];
}
public function messages()
{
return [
'name.required'=>'请填写名称',
];
}
}
... ...
... ... @@ -211,7 +211,8 @@ Route::middleware(['bloginauth'])->group(function () {
//社交绑定
Route::prefix('ayr')->group(function () {
Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
Route::any('/save', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'save_account'])->name('ayr_save_account');
Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account');
Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account');
Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account');
... ...