作者 lyh

gx

@@ -103,6 +103,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K @@ -103,6 +103,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
103 return $this->http_click('get',$url,[],$this->headers); 103 return $this->http_click('get',$url,[],$this->headers);
104 } 104 }
105 105
  106 +
106 /** 107 /**
107 * @name :(发帖)post_send_msg 108 * @name :(发帖)post_send_msg
108 * @author :lyh 109 * @author :lyh
@@ -116,9 +117,30 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K @@ -116,9 +117,30 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
116 $this->headers['Accept-Encoding'] = 'gzip'; 117 $this->headers['Accept-Encoding'] = 'gzip';
117 $this->headers['Authorization'] = $this->headers['Authorization'].$api_key; 118 $this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
118 $url = $this->path.'/api/post'; 119 $url = $this->path.'/api/post';
119 - return $this->http_click('posts',$url,$param,$this->headers); 120 + return $this->http_post_ayr($url,$param,$api_key);
120 } 121 }
121 122
  123 + public function http_post_ayr($url,$param,$api_key){
  124 + $curl = curl_init();
  125 + curl_setopt_array($curl, array(
  126 + CURLOPT_URL => $url,
  127 + CURLOPT_RETURNTRANSFER => true,
  128 + CURLOPT_ENCODING => '',
  129 + CURLOPT_MAXREDIRS => 10,
  130 + CURLOPT_TIMEOUT => 0,
  131 + CURLOPT_FOLLOWLOCATION => true,
  132 + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  133 + CURLOPT_CUSTOMREQUEST => 'POST',
  134 + CURLOPT_POSTFIELDS => http_build_query($param),
  135 + CURLOPT_HTTPHEADER => array(
  136 + 'Authorization: Bearer '.$api_key,
  137 + 'Accept-Encoding: gzip'
  138 + ),
  139 + ));
  140 + $response = curl_exec($curl);
  141 + curl_close($curl);
  142 + echo $response;
  143 + }
122 /** 144 /**
123 * @name :(上传图片或视频到ayr_share)post_media_upload 145 * @name :(上传图片或视频到ayr_share)post_media_upload
124 * @author :lyh 146 * @author :lyh
@@ -64,7 +64,7 @@ if(!function_exists('http_post')){ @@ -64,7 +64,7 @@ if(!function_exists('http_post')){
64 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 64 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
65 $res = curl_exec($ch); 65 $res = curl_exec($ch);
66 if (curl_errno($ch)) { 66 if (curl_errno($ch)) {
67 - Log::write(print_r(curl_errno($ch),1),'debug---1'); 67 + \Illuminate\Support\Facades\Log::write(print_r(curl_errno($ch),1),'debug---1');
68 } 68 }
69 curl_close($ch); 69 curl_close($ch);
70 return json_decode($res, true); 70 return json_decode($res, true);
@@ -7,7 +7,7 @@ use App\Helper\AyrShare as AyrShareHelper; @@ -7,7 +7,7 @@ use App\Helper\AyrShare as AyrShareHelper;
7 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
8 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; 8 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
9 use App\Http\Logic\Bside\AyrShare\AyrShareLogic; 9 use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
10 -use App\Http\Requests\Bside\AyrRelease\AyrReleaseRequest; 10 +use App\Http\Requests\Bside\AyrShare\AyrReleaseRequest;
11 11
12 /** 12 /**
13 * @name:社交发布 13 * @name:社交发布
@@ -66,16 +66,23 @@ class AyrReleaseController extends BaseController @@ -66,16 +66,23 @@ class AyrReleaseController extends BaseController
66 'files'=>$this->param['video'], 66 'files'=>$this->param['video'],
67 ]; 67 ];
68 //参数处理 68 //参数处理
69 - $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);; 69 + $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);
  70 + //时间处理
  71 + $datetime = new \DateTime($this->param['idempotency_key']);
  72 + $formattedTime = $datetime->format("Y-m-d\TH:i:s\Z");
70 //统一生成发布 73 //统一生成发布
71 $param = [ 74 $param = [
72 'post'=>$this->param['content'], 75 'post'=>$this->param['content'],
73 'platforms'=>$this->param['platforms'], 76 'platforms'=>$this->param['platforms'],
74 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 77 'mediaUrls'=>$this->param['mediaUrls'],//参数处理
75 - 'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布) 78 + 'idempotencyKey'=>$formattedTime,//时间(如是过去时间,立即发布)
76 ]; 79 ];
  80 + var_dump($param);
  81 + die();
77 //发送请求发布社交文章 82 //发送请求发布社交文章
78 $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); 83 $res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
  84 + var_dump($res);
  85 + die();
79 //保存数据库 86 //保存数据库
80 $ayrReleaseLogic->release_add(); 87 $ayrReleaseLogic->release_add();
81 $this->response('success',Code::SUCCESS,$res); 88 $this->response('success',Code::SUCCESS,$res);
@@ -61,10 +61,10 @@ class AyrReleaseLogic extends BaseLogic @@ -61,10 +61,10 @@ class AyrReleaseLogic extends BaseLogic
61 $imageModel = new Image(); 61 $imageModel = new Image();
62 $list = $imageModel->list(['hash'=>['in',$images]],'id'); 62 $list = $imageModel->list(['hash'=>['in',$images]],'id');
63 foreach ($list as $v1){ 63 foreach ($list as $v1){
64 - $arr[] = $v1['ayr_url']; 64 + $arr[] = url('/b/image/' . $v1['hash'].'/'.rand(10000,99999).'.'.$v1['type']);
65 } 65 }
66 }else{ 66 }else{
67 - $arr[] = url('/b/file_hash/' . $v.rand(10000,99999).'mp4'); 67 + $arr[] = url('/b/file_hash/' .'/'. $v.rand(10000,99999).'.mp4');
68 } 68 }
69 } 69 }
70 return $this->success($arr); 70 return $this->success($arr);
@@ -215,10 +215,10 @@ class AyrShareLogic extends BaseLogic @@ -215,10 +215,10 @@ class AyrShareLogic extends BaseLogic
215 $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图'); 215 $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图');
216 } 216 }
217 //验证图片数 217 //验证图片数
218 - $img_num = count($this->param['video']);  
219 - if($img_num > 1){  
220 - $this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频');  
221 - } 218 +// $img_num = count($this->param['video']);
  219 +// if($img_num > 1){
  220 +// $this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频');
  221 +// }
222 } 222 }
223 return $this->success(); 223 return $this->success();
224 } 224 }
1 <?php 1 <?php
2 2
3 -namespace App\Http\Requests\Bside\AyrRelease; 3 +namespace App\Http\Requests\Bside\AyrShare;
4 4
5 use Illuminate\Foundation\Http\FormRequest; 5 use Illuminate\Foundation\Http\FormRequest;
6 6