|
@@ -6,6 +6,8 @@ use GuzzleHttp\Client;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Modules\Common\Errors\Errors;
|
|
use Modules\Common\Errors\Errors;
|
|
use Modules\Common\Exceptions\CommonBusinessException;
|
|
use Modules\Common\Exceptions\CommonBusinessException;
|
|
|
|
+use Modules\Common\Support\Http\HttpRequest;
|
|
|
|
+use Modules\Common\Support\Http\WechatURL;
|
|
use Modules\Manage\Services\WechatMiniprogramService;
|
|
use Modules\Manage\Services\WechatMiniprogramService;
|
|
|
|
|
|
|
|
|
|
@@ -19,12 +21,10 @@ class WechatCheckSyncService
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
*/
|
|
public static function pullupload($item, $accessToken) {
|
|
public static function pullupload($item, $accessToken) {
|
|
- $url = 'https://api.weixin.qq.com/wxa/sec/vod/pullupload?access_token='.$accessToken;
|
|
|
|
- $parsedContent = self::postWechat($url, [
|
|
|
|
|
|
+ return HttpRequest::simplePost(WechatURL::vod_pullupload. $accessToken, [
|
|
'media_name' => $item->media_name,
|
|
'media_name' => $item->media_name,
|
|
'media_url' => $item->video_url
|
|
'media_url' => $item->video_url
|
|
]);
|
|
]);
|
|
- return $parsedContent['task_id'];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -46,13 +46,11 @@ class WechatCheckSyncService
|
|
}
|
|
}
|
|
$mediaId = $syncInfo->media_id;
|
|
$mediaId = $syncInfo->media_id;
|
|
$accessToken = WechatMiniprogramService::getDuanjuCheckAccessToken($syncInfo->appid);
|
|
$accessToken = WechatMiniprogramService::getDuanjuCheckAccessToken($syncInfo->appid);
|
|
- $url = 'https://api.weixin.qq.com/wxa/sec/vod/getmedialink?access_token='.$accessToken;
|
|
|
|
|
|
|
|
- $parsedContent = self::postWechat($url, [
|
|
|
|
|
|
+ return HttpRequest::simplePost(WechatURL::vod_getmedialink. $accessToken, [
|
|
'media_id' => $mediaId,
|
|
'media_id' => $mediaId,
|
|
't' => time() + 7200,
|
|
't' => time() + 7200,
|
|
]);
|
|
]);
|
|
- return $parsedContent['media_info'];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public static function getWechatMediaLinkRedisKey($seriesId) {
|
|
public static function getWechatMediaLinkRedisKey($seriesId) {
|
|
@@ -60,44 +58,15 @@ class WechatCheckSyncService
|
|
}
|
|
}
|
|
|
|
|
|
public static function getTask($syncInfo) {
|
|
public static function getTask($syncInfo) {
|
|
- try {
|
|
|
|
- $accessToken = WechatMiniprogramService::getDuanjuCheckAccessToken($syncInfo->appid);
|
|
|
|
- $url = 'https://api.weixin.qq.com/wxa/sec/vod/gettask?access_token='.$accessToken;
|
|
|
|
- $parsedContent = self::postWechat($url, [
|
|
|
|
- 'task_id' => $syncInfo->sync_task_id
|
|
|
|
- ]);
|
|
|
|
|
|
+ $accessToken = WechatMiniprogramService::getDuanjuCheckAccessToken($syncInfo->appid);
|
|
|
|
+ $parsedContent = HttpRequest::simplePost(WechatURL::vod_gettask . $accessToken, [
|
|
|
|
+ 'task_id' => $syncInfo->sync_task_id
|
|
|
|
+ ]);
|
|
|
|
+ if(false === $parsedContent || (0 != $parsedContent['errcode'] ?? 0)) {
|
|
return $parsedContent['task_info'];
|
|
return $parsedContent['task_info'];
|
|
- } catch (\Exception $exception) {
|
|
|
|
|
|
+ } else {
|
|
return [];
|
|
return [];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * post 请求微信上游
|
|
|
|
- * @param $url
|
|
|
|
- * @param $data
|
|
|
|
- * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
- */
|
|
|
|
- public static function postWechat($url, $data) {
|
|
|
|
- $client = new Client(['timeout' => 3]);
|
|
|
|
- $httpResult = $client->post($url, $data);
|
|
|
|
-
|
|
|
|
- $httpStatus = $httpResult->getStatusCode();
|
|
|
|
- if(200 != $httpStatus) {
|
|
|
|
- CommonBusinessException::throwError(Errors::REQUEST_HTTP_STATUS_ERROR);
|
|
|
|
- }
|
|
|
|
- $httpContent = $httpResult->getBody()->getContents();
|
|
|
|
- $parsedContent = \json_decode($httpContent, true);
|
|
|
|
- if(0 != ($parsedContent['errcode'] ?? 0)) {
|
|
|
|
- myLog('WechatCheckSync')->error('请求微信异常', [
|
|
|
|
- 'url' => $url,
|
|
|
|
- 'data' => $data,
|
|
|
|
- 'errMsg' => $httpContent
|
|
|
|
- ]);
|
|
|
|
- CommonBusinessException::throwError(Errors::REQUEST_CODE_STATUS_ERROR);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $parsedContent;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|