regionId('cn-hangzhou') ->asDefaultClient(); try { $result = AlibabaCloud::rpc() ->product('vod') // ->scheme('https') // https | http ->version('2017-03-21') ->action('GetPlayInfo') ->method('POST') ->host('vod.cn-shanghai.aliyuncs.com') ->options([ 'query' => [ 'RegionId' => "cn-hangzhou", 'VideoId' => $video_id, 'PlayConfig' => '{"PlayDomain":"'.$play_domain.'"}', ], 'headers' =>[ 'referer' => 'https://lova.ufutx.com' ] ]) ->request(); $result = $result->toArray(); return $result; } catch (ClientException $e) { throw new \Exception($e->getMessage(),$e->getCode()); } catch (ServerException $e) { throw new \Exception($e->getMessage(),$e->getCode()); } catch (\Exception $e) { throw new \Exception($e->getMessage(),$e->getCode()); } } public function getLocalMobile() { AlibabaCloud::accessKeyClient(env('ALIYUN_MOBILE_ACCESS_KEY_ID'), env('ALIYUN_MOBILE_ACCESS_KEY_SECRET')) ->regionId('cn-hangzhou') ->asDefaultClient(); $token = request()->input('access_token'); if (empty($token)) return ['code'=>1, 'msg'=>'缺少参数']; try { $result = AlibabaCloud::rpc() ->product('Dypnsapi') ->scheme('https') // https | http ->version('2017-05-25') ->action('GetMobile') ->method('POST') ->host('dypnsapi.aliyuncs.com') ->options([ 'query' => [ 'RegionId' => "cn-hangzhou", 'AccessToken' => $token, ], ]) ->request(); $result = $result->toArray(); if ($result['Code'] == 'OK') { return $result['GetMobileResultDTO']['Mobile']; } return false; } catch (ClientException $e) { $this->getError($e); return false; } catch (ServerException $e) { $this->getError($e); return false; } catch (\Exception $e) { $this->getError($e); return false; } } /** * 提交转码作业 * @param $video_id * @return array * @throws ClientException */ public function SubmitTranscodeJobs($video_id){ AlibabaCloud::accessKeyClient(env('ALIYUN_VOD_ACCESS_KEY_ID'), env('ALIYUN_VOD_ACCESS_KEY_SECRET')) ->regionId('cn-hangzhou') ->asDefaultClient(); try { $result = AlibabaCloud::rpc() ->product('vod') // ->scheme('https') // https | http ->version('2017-03-21') ->action('SubmitTranscodeJobs') ->method('POST') ->host('vod.cn-shanghai.aliyuncs.com') ->options([ 'query' => [ 'RegionId' => "cn-hangzhou", 'VideoId' => $video_id, 'TemplateGroupId' => '0945f5dd3a9372ce390cf41d6d35e96b' ], ]) ->request(); $result = $result->toArray(); return $result; } catch (ClientException $e) { throw new \Exception($e->getMessage(),$e->getCode()); } catch (ServerException $e) { throw new \Exception($e->getMessage(),$e->getCode()); } catch (\Exception $e) { throw new \Exception($e->getMessage(),$e->getCode()); } } /** * URL鉴权 * @param $filePath * @param $key * @param $domain * @param $expireTime * @return string */ static function Video_Url_Auth($url, $key, $expireTime) { $url = parse_url($url); $timeStamp = time() + $expireTime; $rand = md5(uniqid(microtime(true),true)); $sstring = $url['host'] . '-' . $timeStamp . '-'.$rand.'-0-' . $key; $md5hash = md5($sstring); $url = 'http://' . $url['host'] . $url['path'] . '?auth_key=' . $timeStamp . '-'.$rand.'-0-' . $md5hash; return $url; } }