作者 赵彬吉

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

  1 +<?php
  2 +
  3 +namespace App\Helper;
  4 +
  5 +use GuzzleHttp\Client;
  6 +
  7 +/**
  8 + * @name: ayr_share社交绑定
  9 + */
  10 +class AyrShare
  11 +{
  12 + public $path = 'https://app.ayrshare.com/api';
  13 + //api_key
  14 + public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB';
  15 + //系统设置
  16 + public $config = [
  17 +
  18 + ];
  19 + //profile_key
  20 + public $profile_key = "-----BEGIN RSA PRIVATE KEY-----
  21 + MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
  22 + 9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
  23 + h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
  24 + gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
  25 + Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
  26 + uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
  27 + DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
  28 + 52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
  29 + CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
  30 + EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
  31 + yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
  32 + yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
  33 + zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
  34 + -----END RSA PRIVATE KEY-----";
  35 + //设置请求头
  36 + public $headers = [
  37 + 'Authorization' => 'Bearer ',
  38 + 'Content-Type' => 'application/json',
  39 +// 'Accept-Encoding' => 'deflate, gzip',
  40 + ];
  41 +
  42 + /**
  43 + * @name :参数构建
  44 + */
  45 + public function __construct()
  46 + {
  47 + $this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
  48 + }
  49 +
  50 + /**
  51 + * @name :获取过去30天发布的历史记录(1-30)
  52 + * @author :lyh
  53 + * @method :get
  54 + * @time :2023/5/5 10:00
  55 + */
  56 + public function get_analytics_links($to_day){
  57 + $last_days = (string)$to_day;
  58 + $url = $this->path.'/analytics/links?lastDays='.$last_days;
  59 + return $this->http_click('get',$url);
  60 + }
  61 +
  62 + /**
  63 + * @name :(通过 Ayrshare 获取给定帖子的实时分析,例如点赞、印象、转推等)post_analytics
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/5/5 11:56
  67 + */
  68 + public function post_analytics($id){
  69 + $param = [
  70 + 'id'=>$id,
  71 + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
  72 + ];
  73 + $url = $this->path.'/api/analytics/post';
  74 + return $this->http_click('post', $url, $param);
  75 + }
  76 + /**
  77 + * @name :(获取特定用户个人资料)analytics_post
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2023/5/5 10:43
  81 + */
  82 + public function post_analytics_social(){
  83 + $post_data = [
  84 + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
  85 + ];
  86 + $url = $this->path.'/api/analytics/social';
  87 + return $this->http_click('post',$url,$post_data);
  88 + }
  89 +
  90 + /**
  91 + * @name :(设置自动计划)post_schedule_set
  92 + * @author :lyh
  93 + * @method :post
  94 + * @time :2023/5/5 13:58
  95 + */
  96 + public function post_schedule_set($data){
  97 + $param = [
  98 + 'schedule'=>["13:05Z", "20:14Z"],
  99 + 'title'=>$data['title'],
  100 + ];
  101 + $url = $this->path.'/api/auto-schedule/set';
  102 + return $this->http_click('post',$url,$param);
  103 + }
  104 +
  105 + /**
  106 + * @name :(删除自动计划)delete_schedule
  107 + * @author :lyh
  108 + * @method :post
  109 + * @time :2023/5/5 14:04
  110 + */
  111 + public function delete_schedule($data){
  112 + $param = [
  113 + 'title'=>$data['title'],
  114 + ];
  115 + $url = $this->path.'/api/auto-schedule/delete';
  116 + return $this->http_click('delete',$url,$param);
  117 + }
  118 +
  119 + /**
  120 + * @name :(列出自动计划)get_schedule_list
  121 + * @author :lyh
  122 + * @method :post
  123 + * @time :2023/5/5 14:08
  124 + */
  125 + public function get_schedule_list(){
  126 + $url = $this->path.'/api/auto-schedule/list';
  127 + return $this->http_click('get',$url);
  128 + }
  129 +
  130 + /**
  131 + * @name :(发布到用户个人资料)post_user
  132 + * @author :lyh
  133 + * @method :post
  134 + * @time :2023/5/5 15:00
  135 + */
  136 + public function post_user($data){
  137 + $param = [
  138 + 'post'=>$data['post'],
  139 + 'platforms'=>$data['platforms'],
  140 + 'profileKey'=>$this->profile_key,
  141 + 'mediaUrls'=>$data['mediaUrls']
  142 + ];
  143 + $url = $this->path.'/api/post';
  144 + return $this->http_click('post',$url,$param);
  145 + }
  146 +
  147 + /**
  148 + * @name :(创建子账户相关操作)post_create_profiles
  149 + * @author :lyh
  150 + * @method :post
  151 + * @time :2023/5/5 15:16
  152 + */
  153 + public function post_create_profiles($data){
  154 + $param = [
  155 + 'title'=>$data['title'],
  156 + ];
  157 + $url = $this->path.'/profiles/profile';
  158 + return $this->http_click('post',$url,$param);
  159 + }
  160 + /**
  161 + * @name :(删除子账户相关操作)post_create_profiles
  162 + * @author :lyh
  163 + * @method :post
  164 + * @time :2023/5/5 15:16
  165 + */
  166 + public function deleted_create_profiles($data){
  167 + $param = [
  168 + 'title'=>$data['title'],
  169 + 'profileKey'=>$this->profile_key,
  170 + ];
  171 + $url = $this->path.'/profiles/profile';
  172 + return $this->http_click('delete',$url,$param);
  173 + }
  174 +
  175 + public function put_update_profiles($data){
  176 + $param = [
  177 + 'title'=>$data['title'],
  178 + 'profileKey'=>$this->profile_key,
  179 + ];
  180 + $url = $this->path.'/profiles/profile';
  181 + return $this->http_click('put',$url,$param);
  182 + }
  183 + /**
  184 + * @name :(获取有关用户社交资料的分析和人口统计,例如印象,视图和关注着)post_social
  185 + * @author :lyh
  186 + * @method :post
  187 + * @time :2023/5/5 10:37
  188 + */
  189 + public function api_user(){
  190 + $post_data = [
  191 + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
  192 + ];
  193 + $url = $this->path.'/api/user';
  194 + return $this->http_click('post',$url,$post_data);
  195 + }
  196 +
  197 +
  198 + /**
  199 + * 发送http post,get,put,delete请求
  200 + * @param type $url
  201 + * @param type $post_data
  202 + */
  203 + function http_click($method = 'post',$url, $param = [],$header = [])
  204 + {
  205 + if(!empty($param)){
  206 + $post_data['json'] = $param;
  207 + }
  208 + $post_data['headers'] = !empty($header) ? $header : $this->headers;
  209 + $client = new Client();
  210 + try {
  211 + $res = $client->request(strtoupper($method), $url, $post_data)->getBody()->getContents();
  212 + return $res;
  213 + } catch (\Exception $e) {
  214 + return json_encode(["status"=>"fail","message"=>$e->getMessage()]);
  215 + }
  216 + }
  217 +}
@@ -7,6 +7,9 @@ use App\Models\User\UserLog as UserLogModel; @@ -7,6 +7,9 @@ use App\Models\User\UserLog as UserLogModel;
7 use App\Models\User\UserLogin as UserLoginModel; 7 use App\Models\User\UserLogin as UserLoginModel;
8 use Illuminate\Support\Facades\Cache; 8 use Illuminate\Support\Facades\Cache;
9 9
  10 +/**
  11 + * @name:
  12 + */
10 class Common 13 class Common
11 { 14 {
12 /** 15 /**
@@ -4,6 +4,9 @@ namespace App\Helper; @@ -4,6 +4,9 @@ namespace App\Helper;
4 4
5 use App\Models\WebSetting\WebSettingCountry; 5 use App\Models\WebSetting\WebSettingCountry;
6 6
  7 +/**
  8 + * @name:多语言国家设置
  9 + */
7 class Country 10 class Country
8 { 11 {
9 public $tls_list = [ 12 public $tls_list = [
@@ -681,6 +684,6 @@ class Country @@ -681,6 +684,6 @@ class Country
681 } 684 }
682 $webCountry = new WebSettingCountry(); 685 $webCountry = new WebSettingCountry();
683 $webCountry->insert($data); 686 $webCountry->insert($data);
684 - return; 687 + return true;
685 } 688 }
686 } 689 }
@@ -42,12 +42,14 @@ if(!function_exists('http_post')){ @@ -42,12 +42,14 @@ if(!function_exists('http_post')){
42 * @param type $url 42 * @param type $url
43 * @param type $post_data 43 * @param type $post_data
44 */ 44 */
45 - function http_post($url, $post_data) 45 + function http_post($url, $post_data,$header = [])
46 { 46 {
47 - $header = array(  
48 - "Accept: application/json",  
49 - "Content-Type:application/json;charset=utf-8",  
50 - ); 47 + if(empty($header)){
  48 + $header = array(
  49 + "Accept: application/json",
  50 + "Content-Type:application/json;charset=utf-8",
  51 + );
  52 + }
51 $ch = curl_init(); 53 $ch = curl_init();
52 curl_setopt($ch, CURLOPT_URL, $url); 54 curl_setopt($ch, CURLOPT_URL, $url);
53 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 55 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -74,10 +76,12 @@ if(!function_exists('http_get')){ @@ -74,10 +76,12 @@ if(!function_exists('http_get')){
74 * @param type $url 76 * @param type $url
75 * @return type 77 * @return type
76 */ 78 */
77 - function http_get($url) 79 + function http_get($url,$header = [])
78 { 80 {
79 - $header[] = "content-type: application/x-www-form-urlencoded; 81 + if(empty($header)){
  82 + $header[] = "content-type: application/json;
80 charset = UTF-8"; 83 charset = UTF-8";
  84 + }
81 $ch1 = curl_init(); 85 $ch1 = curl_init();
82 $timeout = 5; 86 $timeout = 5;
83 curl_setopt($ch1, CURLOPT_URL, $url); 87 curl_setopt($ch1, CURLOPT_URL, $url);
@@ -22,7 +22,7 @@ class BlogController extends BaseController @@ -22,7 +22,7 @@ class BlogController extends BaseController
22 //搜索条件 22 //搜索条件
23 $this->map['project_id'] = $this->user['project_id']; 23 $this->map['project_id'] = $this->user['project_id'];
24 $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order, 24 $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order,
25 - ['id','category_id','operator_id','status','created_at','label_id','updated_at','name','sort','url']); 25 + ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
26 if(!empty($lists['list'])){ 26 if(!empty($lists['list'])){
27 foreach ($lists['list'] as $k => $v){ 27 foreach ($lists['list'] as $k => $v){
28 //获取分类名称 28 //获取分类名称
@@ -25,7 +25,7 @@ class NewsController extends BaseController @@ -25,7 +25,7 @@ class NewsController extends BaseController
25 public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ 25 public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
26 $this->map['project_id'] = $this->user['project_id']; 26 $this->map['project_id'] = $this->user['project_id'];
27 $lists = $news->lists($this->map,$this->page,$this->row,$this->order, 27 $lists = $news->lists($this->map,$this->page,$this->row,$this->order,
28 - ['id','category_id','operator_id','status','created_at','updated_at','name','sort','url']); 28 + ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
29 if(!empty($lists['list'])){ 29 if(!empty($lists['list'])){
30 foreach ($lists['list'] as $k => $v){ 30 foreach ($lists['list'] as $k => $v){
31 $v = $newsCategoryLogic->get_category_name($v); 31 $v = $newsCategoryLogic->get_category_name($v);
@@ -6,8 +6,6 @@ use App\Enums\Common\Code; @@ -6,8 +6,6 @@ use App\Enums\Common\Code;
6 use App\Models\Image as ImageModel; 6 use App\Models\Image as ImageModel;
7 use Illuminate\Http\Exceptions\HttpResponseException; 7 use Illuminate\Http\Exceptions\HttpResponseException;
8 use Illuminate\Http\JsonResponse; 8 use Illuminate\Http\JsonResponse;
9 -use Illuminate\Http\Request;  
10 -use Illuminate\Support\Facades\DB;  
11 use Illuminate\Support\Facades\Storage; 9 use Illuminate\Support\Facades\Storage;
12 use Intervention\Image\Facades\Image; 10 use Intervention\Image\Facades\Image;
13 11
@@ -32,9 +30,9 @@ class ImageController @@ -32,9 +30,9 @@ class ImageController
32 30
33 public $request = ''; 31 public $request = '';
34 32
35 - public function __construct(Request $request) 33 + public function __construct()
36 { 34 {
37 - $this->request = $request; 35 + $this->request = request();
38 $this->config = config('filesystems.disks.upload'); 36 $this->config = config('filesystems.disks.upload');
39 $this->path = $this->config['root']; 37 $this->path = $this->config['root'];
40 } 38 }
@@ -60,19 +60,19 @@ class NewsLogic extends BaseLogic @@ -60,19 +60,19 @@ class NewsLogic extends BaseLogic
60 $this->param['project_id'] = $this->user['project_id']; 60 $this->param['project_id'] = $this->user['project_id'];
61 $this->param['created_at'] = date('Y-m-d H:i:s',time()); 61 $this->param['created_at'] = date('Y-m-d H:i:s',time());
62 $this->param['updated_at'] = date('Y-m-d H:i:s',time()); 62 $this->param['updated_at'] = date('Y-m-d H:i:s',time());
63 - DB::beginTransaction();  
64 - try { 63 +// DB::beginTransaction();
  64 +// try {
65 if(isset($this->param['image'])){ 65 if(isset($this->param['image'])){
66 $data = $this->upload(); 66 $data = $this->upload();
67 $this->param['image'] = $data; 67 $this->param['image'] = $data;
68 } 68 }
69 $rs = $this->model->insertGetId($this->param); 69 $rs = $this->model->insertGetId($this->param);
70 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); 70 RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
71 - DB::commit();  
72 - }catch (\Exception $e){  
73 - DB::rollBack();  
74 - $this->fail('添加失败');  
75 - } 71 +// DB::commit();
  72 +// }catch (\Exception $e){
  73 +// DB::rollBack();
  74 +// $this->fail('添加失败');
  75 +// }
76 return $this->success(); 76 return $this->success();
77 } 77 }
78 78
@@ -25,7 +25,7 @@ class NewsRequest extends FormRequest @@ -25,7 +25,7 @@ class NewsRequest extends FormRequest
25 { 25 {
26 return [ 26 return [
27 'name'=>'required|max:100', 27 'name'=>'required|max:100',
28 - 'remark'=>'required|max:100', 28 + 'remark'=>'required|max:255',
29 'text'=>'required|min:10', 29 'text'=>'required|min:10',
30 'category_id'=>'required', 30 'category_id'=>'required',
31 ]; 31 ];