作者 lyh

gx

... ... @@ -14,7 +14,13 @@ class AyrShare
public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB';
//系统设置
public $config = [
'facebook'=>'#best https://www.facebook.com',
'google'=>'#best https://www.google.com',
'instagram'=>'#best https://www.instagram.com',
'linkedin'=>'#best https://www.linkedin.com',
'twitter'=>'#best https://www.twitter.com',
'telegram'=>'#best https://www.telegram.com',
'tiktok'=>'#bestvideo',
];
//profile_key
public $profile_key = '';
... ... @@ -86,42 +92,57 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
}
/**
* @name :(获取当前用户的配置文件)get_profiles
* @name :(获取指定api_key的配置文件)get_profiles_users
* @author :lyh
* @method :post
* @time :2023/5/6 16:01
* @time :2023/5/6 16:44
*/
public function get_profiles(){
$url = $this->path.'/api/profiles';
return $this->http_click('get',$url,[]);
public function get_profiles_users($api_key){
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/user';
return $this->http_click('get',$url,[],$this->headers);
}
/**
* @name :(获取所有用户的配置文件)get_profiles_users
* @name :(发帖)post_send_msg
* @author :lyh
* @method :post
* @time :2023/5/6 16:44
* @time :2023/5/8 9:22
* @param :platforms: "facebook", "fbg", "twitter",
* "linkedin", "instagram","youtube", "reddit" ,"telegram""
*/
public function get_profiles_users($api_key){
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/user';
return $this->http_click('get',$url,[],$this->headers);
public function post_send_msg($param){
$param = [
'post'=>$param['post'],//内容(帖子文本)
'platforms'=>$param['platforms'],//平台
'idempotencyKey'=>$param['idempotencyKey'],//帖子唯一id
'mediaUrls'=>$param['mediaUrls'],
];
//平台参数处理
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
$url = $this->path.'/api/post';
return $this->http_click('posts',$url,$param,$this->headers);
}
/**
* @name :(通过用户名获取社交账号)get_brand_user
* @author :lyh https://app.ayrshare.com/api/brand/byUser
* @name :(上传图片或视频到ayr_share)post_media_upload
* @author :lyh
* @method :post
* @time :2023/5/5 17:32
* @time :2023/5/8 9:47
* https://app.ayrshare.com/api/media/upload
*/
public function get_brand_user($param){
//[[platforms=>'instagram','instagramUser'=>'user']]
$str = '';
foreach ($param as $k =>$v){
//platforms[0]=instagram&platforms[1]=twitter&twitterUser=ayrshare&instagramUser=nygiants',
}
$url = $this->path.'/api/brand/byUser?'.$str;
return $this->http_click('get',$url);
public function post_media_upload($data){
$param = [
'file'=>$data['file'],//base64编码
'fileName'=>$data['file_name'],//生成图片名称
'description'=>$data['description'],//描述
];
$this->headers['Authorization'] = $this->headers['Authorization'].$data['profile_key'];
$url = $this->path.'/api/media/upload';
return $this->http_click('posts',$url,$param,$this->headers);
}
/**
* @name :获取过去30天发布的历史记录(1-30)
* @author :lyh
... ...
... ... @@ -127,4 +127,28 @@ class AyrShareController extends BaseController
}
$this->response('success',Code::SUCCESS,$res);
}
/**
* @name :(上传图片到第三方)post_uploads
* @author :lyh
* @method :post
* @time :2023/5/8 13:45
*/
public function post_uploads(){
}
/**
* @name :(发布推文到第三方平台)send_api_post
* @author :lyh
* @method :post
* @time :2023/5/8 13:37
*/
public function send_api_post(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
}
}
... ...
<?php
namespace App\Http\Controllers\Bside\Setting;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingTextLogic;
class WebSettingTextController extends BaseController
{
/**
* @name :lists
* @author :lyh
* @method :post
* @time :2023/5/4 11:28
*/
public function lists(WebSettingTextLogic $webSettingTextLogic){
$anchor_text = config('setting.anchor_text');
$lists = $webSettingTextLogic->setting_text_lists();
$lists['anchor_text'] = $anchor_text;
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :save
* @author :lyh
* @method :post
* @time :2023/4/28 14:46
*/
public function save(WebSettingTextLogic $webSettingTextLogic){
$webSettingTextLogic->setting_text_save();
$this->response('success');
}
}
... ...
<?php
namespace App\Http\Controllers\file;
use App\Enums\Common\Code;
use App\Models\File\File;
class FileController
{
public $upload_img = [
//设置静态缓存参数(304)
'header' => [
'Cache-Control' => 'max-age=2592000',
'Pragma' => 'cache',
'Expires' => "%Expires%", // cache 1 month
'etag' => "%etag%",
'Last-Modified' => "%Last-Modified%",
'Content-Description' => 'File Transfer',
],
];
public $path = '';
public $config = '';
public $thr_path = '';
public $request = '';
public function __construct()
{
$this->request = request();
$this->config = config('filesystems.disks.upload');
$this->path = $this->config['root'];
}
public function index($hash = '', $w = 0 ,$h = 0){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
}
$file_model = new File();
$info = $file_model->read(['hash'=>$hash]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$path = $info['path'];
if (!is_file($path)) {
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
}
$content = file_get_contents($path);
$header['Content-Length'] = $info['size'];
return response($content, 200, $header);
}
}
... ...
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\file;
use App\Enums\Common\Code;
use App\Models\Image as ImageModel;
use App\Http\Controllers\type;
use App\Http\Controllers\统一返回参数;
use App\Models\File\Image as ImageModel;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Storage;
... ... @@ -114,12 +116,12 @@ class ImageController
}
$url = $this->path;
$filename = date('ymdHis').rand(10000,99999);
$res = $this->request->file('image')->move($url,$filename);
$res = $this->request->file('image')->move($url);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$data = [
'path' => $url.'/'.$filename,
'path' => $url.'/'.$res->getClientOriginalName(),
'created_at' => date('Y-m-d H:i:s',time()),
'size' => $res->getSize(),
'hash' => $hash,
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\AyrShare;
use App\Helper\AyrShare as AyrShareHelper;
use App\Http\Controllers\file\ImageController;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\AyrShare\AyrShare;
... ... @@ -67,6 +68,27 @@ class AyrShareLogic extends BaseLogic
}
return $this->success();
}
/**
* @name :(向第三方平台发布帖子)api_public_msg
* @author :lyh
* @method :post
* @time :2023/5/8 9:11
*/
public function send_public_post($param){
//获取图片
$image_c = new ImageController();
$image_info = $image_c->index($param['hash']);
$param = [
'post'=>$param['text'],
'mediaUrls'=>$image_info,
'platforms'=>$this->param['platforms'],
];
//发布帖子
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_send_msg($param);
$this->success($res);
}
}
... ...
... ... @@ -5,7 +5,7 @@ namespace App\Http\Logic\Bside;
use App\Enums\Common\Common;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\ImageController;
use App\Http\Controllers\file\ImageController;
use App\Http\Logic\Logic;
use Illuminate\Support\Facades\Cache;
... ...
... ... @@ -7,7 +7,6 @@ use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\Image;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
... ...
... ... @@ -5,7 +5,6 @@ namespace App\Http\Logic\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\News\News;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap;
... ...
... ... @@ -3,7 +3,7 @@
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\File\Image;
use App\Models\WebSetting\WebSettingService;
use Illuminate\Support\Facades\DB;
... ...
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingText;
class WebSettingTextLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingText();
$this->param = $this->requestAll;
}
/**
* @name :(描文本详情)setting_text_lists
* @author :lyh
* @method :post
* @time :2023/5/8 14:18
*/
public function setting_text_lists(){
$lists = $this->model->list(['project_id'=>$this->user['project_id']]);
$this->success($lists);
}
}
... ...
... ... @@ -3,9 +3,7 @@
namespace App\Http\Logic\Bside\User;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Image;
use App\Models\User\User;
class UserLogic extends BaseLogic
... ...
<?php
namespace App\Models\AyrShare;
use App\Models\Base;
class AyrRelease extends Base
{
protected $table = 'gl_ayr_release';
}
... ...
<?php
namespace App\Models\File;
use App\Models\Base;
class File extends Base
{
protected $table = 'gl_file';
}
... ...
<?php
namespace App\Models;
namespace App\Models\File;
use App\Models\Base;
class Image extends Base
{
... ...
<?php
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingText extends Base
{
protected $table = 'gl_web_setting_text';
}
... ...
<?php
return [
//锚文本相关设置
'anchor_text'=>[
'is_enable'=>false,
'num'=>3,
'text_view'=>[
'单页面',
'产品页',
'关键词也',
'新闻页',
'博客页',
],
],
];
... ...
... ... @@ -180,7 +180,7 @@ Route::middleware(['bloginauth'])->group(function () {
});
//图片操作
Route::prefix('images')->group(function () {
Route::post('/upload', [\App\Http\Controllers\ImageController::class, 'upload'])->name('image_upload');
Route::post('/upload', [\App\Http\Controllers\file\ImageController::class, 'upload'])->name('image_upload');
});
//精准询盘
... ... @@ -209,5 +209,5 @@ Route::group([], function () {
Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\ImageController::class,'index'])->name('image_show');
Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
});
... ...