This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
快手、好看视频相关接口
- Loading branch information
Showing
4 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"conventionalCommits.scopes": ["kernel", "haokan", "kuaishou", "vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Waset\Haokan; | ||
|
||
class Video extends Application | ||
{ | ||
/** | ||
* 发布视频 | ||
* | ||
* @param string $title | ||
* @param string $video_url | ||
* @param string $cover_images | ||
* @return Video | ||
*/ | ||
public function push(string $title, string $video_url, string $cover_images) | ||
{ | ||
$api_url = self::BaseUrl . '/video/publish'; | ||
|
||
$params = [ | ||
'app_id' => $this->app_id, | ||
'app_token' => $this->app_token, | ||
"title" => $title, | ||
"video_url" => $video_url, | ||
"cover_images" => $cover_images, | ||
]; | ||
|
||
$res = $this->https_post($api_url, $params)->toArray(); | ||
|
||
return $res; | ||
} | ||
|
||
/** | ||
* 获取视频状态 | ||
* | ||
* @param array $article_id | ||
* @return Video | ||
*/ | ||
public function status(array $article_id) | ||
{ | ||
$api_url = self::BaseUrl . '/query/status'; | ||
|
||
$params = [ | ||
'app_id' => $this->app_id, | ||
'app_token' => $this->app_token, | ||
"article_id" => implode(',', $article_id), | ||
]; | ||
|
||
$res = $this->https_post($api_url, $params)->toArray(); | ||
|
||
return $res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
|
||
namespace Waset\Kuaishou; | ||
|
||
class Video extends Application | ||
{ | ||
/** | ||
* 开始上传视频 | ||
* | ||
* @param string $access_token | ||
* @return Video | ||
*/ | ||
public function start_upload(string $access_token) | ||
{ | ||
$api_url = self::BaseUrl . '/openapi/photo/start_upload'; | ||
|
||
$body = [ | ||
'access_token' => $access_token, | ||
'app_id' => $this->app_id, | ||
]; | ||
$res = $this->https_post($api_url, $body)->toArray(); | ||
|
||
return $res; | ||
} | ||
|
||
/** | ||
* 上传视频 | ||
* | ||
* @param string $endpoint | ||
* @param string $upload_token | ||
* @param string $file | ||
* @return Video | ||
*/ | ||
public function upload(string $endpoint, string $upload_token, string $file) | ||
{ | ||
$api_url = "http://${endpoint}/api/upload?upload_token=${upload_token}"; | ||
|
||
|
||
return $this->https_byte($api_url, $file); | ||
} | ||
|
||
/** | ||
* 上传视频 - Multipart Form Data上传 | ||
* | ||
* @param string $endpoint 上传网关的域名 | ||
* @param string $upload_token 上传令牌 | ||
* @param string $file 上传文件 | ||
*/ | ||
public function upload_multipart(string $endpoint, string $upload_token, string $file) | ||
{ | ||
$api_url = "http://${endpoint}/api/upload/multipart?upload_token=${upload_token}"; | ||
|
||
return $this->https_byte($api_url, $file); | ||
} | ||
|
||
/** | ||
* 分片上传 - 上传分片 | ||
* | ||
* @param string $endpoint 上传网关的域名 | ||
* @param string $upload_token 上传令牌 | ||
* @param string $fragment_id 分片id 从0开始 | ||
*/ | ||
public function video_upload_fragment(string $endpoint, string $upload_token, string $fragment_id, mixed $file) | ||
{ | ||
$api_url = "http://${endpoint}/api/upload/fragment"; | ||
$api_url = $this->https_url($api_url, [ | ||
'fragment_id' => $fragment_id, | ||
'upload_token' => $upload_token | ||
]); | ||
|
||
return $this->https_byte($api_url, $file); | ||
} | ||
|
||
/** | ||
* 分片上传 - 断点续传 | ||
* | ||
* @param string $endpoint 上传网关的域名 | ||
* @param string $upload_token 上传令牌 | ||
* @param string $fragment_id 分片id 从0开始 | ||
*/ | ||
public function video_upload_resume(string $endpoint, string $upload_token) | ||
{ | ||
$api_url = "http://${endpoint}/api/upload/resume"; | ||
$api_url = $this->https_url($api_url, [ | ||
'upload_token' => $upload_token | ||
]); | ||
|
||
return $this->https_get($api_url); | ||
} | ||
|
||
/** | ||
* 分片上传 - 完成分片上传 | ||
* | ||
* @param string $endpoint 上传网关的域名 | ||
* @param string $upload_token 上传令牌 | ||
* @param string $fragment_id 分片id 从0开始 | ||
*/ | ||
public function video_upload_complete(string $endpoint, string $upload_token, string $fragment_count) | ||
{ | ||
$api_url = "http://${endpoint}/api/upload/complete"; | ||
$api_url = $this->https_url($api_url, [ | ||
'upload_token' => $upload_token, | ||
'fragment_count' => $fragment_count, | ||
]); | ||
|
||
return $this->https_post($api_url); | ||
} | ||
|
||
|
||
/** | ||
* 发布视频 | ||
* | ||
* @param string $access_token | ||
* @param string $upload_token | ||
* @param string $title | ||
* @param string $cover_images | ||
* @return Video | ||
*/ | ||
public function publish(string $access_token, string $upload_token, string $title, string $cover_images) | ||
{ | ||
$api_url = self::BaseUrl . '/openapi/photo/publish'; | ||
$params = [ | ||
'access_token' => $access_token, | ||
'app_id' => $this->app_id, | ||
'upload_token' => $upload_token | ||
]; | ||
$url = $this->https_url($api_url, $params); | ||
$body = [ | ||
'caption' => $title, | ||
'cover' => file_get_contents($cover_images), | ||
]; | ||
$res = $this->https_post($url, $body)->toArray(); | ||
|
||
return $res; | ||
} | ||
|
||
/** | ||
* 删除视频 | ||
* | ||
* @param string $access_token | ||
* @param string $photo_id | ||
*/ | ||
public function video_delete($access_token, $photo_id) | ||
{ | ||
$api_url = self::BaseUrl . '/openapi/photo/delete'; | ||
|
||
$params = [ | ||
'access_token' => $access_token, | ||
'photo_id' => $photo_id | ||
]; | ||
return $this->https_post($api_url, $params); | ||
} | ||
} |