55use Qencode \Exceptions \QencodeApiException ;
66use Qencode \Exceptions \QencodeException ;
77use Qencode \Classes \TranscodingTask ;
8+ use Qencode \Classes \Metadata ;
89
910/**
1011 * Class QencodeClient
@@ -80,7 +81,7 @@ private function getAccessToken() {
8081 $ response = $ this ->post ("access_token " , array ('api_key ' => $ this ->key ));
8182 $ this ->access_token = $ response ['token ' ];
8283 }
83-
84+
8485 /**
8586 * Returns total available item count from the last request if it supports paging (e.g order list) or null otherwise.
8687 *
@@ -105,6 +106,20 @@ public function post($path, $params = [], $arrays = null)
105106 return $ this ->request ('POST ' , $ path , $ params , $ arrays );
106107 }
107108
109+
110+ /**
111+ * Perform a GET request to the API
112+ * @param string $path Request path (e.g. 'start_encode')
113+ * @param array $data Request body data as an associative array
114+ * @param array $params Additional GET parameters as an associative array
115+ * @return mixed API response
116+ * @throws \Qencode\Exceptions\QencodeApiException if the API call status code is not in the 2xx range
117+ * @throws QencodeException if the API call has failed or the response is invalid
118+ */
119+ public function get ($ path , $ params = [], $ arrays = null )
120+ {
121+ return $ this ->request ('GET ' , $ path , $ params , $ arrays );
122+ }
108123 /**
109124 * Return raw response data from the last request
110125 * @return string|null Response data
@@ -165,7 +180,8 @@ private function request($method, $path, array $params = [], $arrays = null)
165180 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , true );
166181 curl_setopt ($ curl , CURLOPT_FOLLOWLOCATION , true );
167182 curl_setopt ($ curl , CURLOPT_MAXREDIRS , 3 );
168-
183+ curl_setopt ($ curl , CURLOPT_SSL_VERIFYHOST , false );
184+ curl_setopt ($ curl , CURLOPT_SSL_VERIFYPEER , false );
169185 curl_setopt ($ curl , CURLOPT_CONNECTTIMEOUT , $ this ->curlConnectTimeout );
170186 curl_setopt ($ curl , CURLOPT_TIMEOUT , $ this ->curlTimeout );
171187
@@ -190,6 +206,9 @@ private function request($method, $path, array $params = [], $arrays = null)
190206 $ this ->lastResponse = $ response = json_decode ($ this ->lastResponseRaw , true );
191207 //print_r($response);
192208
209+ if ($ method == 'GET ' )
210+ return $ response ;
211+
193212 if (!isset ($ response ['error ' ])) {
194213 $ e = new QencodeException ('Invalid API response ' );
195214 $ e ->rawResponse = $ this ->lastResponseRaw ;
@@ -214,4 +233,15 @@ public function createTask() {
214233 $ task = new TranscodingTask ($ this , $ response ['task_token ' ]);
215234 return $ task ;
216235 }
236+
237+ /**
238+ * @param string
239+ */
240+ public function getMetadata (string $ url )
241+ {
242+ $ response = $ this ->post ('create_task ' , array ('token ' => $ this ->access_token ));
243+ $ metadata = new Metadata ($ this , $ response ['task_token ' ]);
244+ $ videoInfo = $ metadata ->get ($ url );
245+ return $ videoInfo ;
246+ }
217247}
0 commit comments