如何验证 Vimeo 视频 ID?

Rad*_*dex 2 javascript vimeo

我需要创建一个可以验证有效 Vimeo 视频的正则表达式。

根据 Vimeo API,他们仅使用数字作为视频 ID,但不指定长度。

到目前为止我的正则表达式var regEx= /^[0-9]+$/;

我想知道: - vimeo 视频 ID 支持的允许长度是多少?- 如何修改我的正则表达式?

我找到的唯一文章: https://vimeo.com/forums/topic :267078

kem*_*ica 5

与其尝试发明 Vimeo 视频 ID 验证器,为什么不直接使用Vimeo 开发者 API来检查 Vimeo ID 是否有效呢?

GET https://api.vimeo.com/videos/{video_id}

+------------------+--------------------------------------------------+
| Http Status Code | Explanation                                      |
+------------------+--------------------------------------------------+
| 200 Ok           |                                                  |
+------------------+--------------------------------------------------+
| 403              | if the video does exist, but the view or the app |
|                  | requesting the video resource does not have      |
|                  | permission to access that video.                 |
+------------------+--------------------------------------------------+
| 404 not found    | If the video cannot be found.                    |
+------------------+--------------------------------------------------+ 
Run Code Online (Sandbox Code Playgroud)

检查您(1)或用户是否(2)拥有视频:

(1) GET https://api.vimeo.com/me/videos/{video_id}
(2) GET https://api.vimeo.com/users/{user_id}/videos/{video_id}

+------------------+------------------------------------------------------+
| Http Status Code | Explanation                                          |
+------------------+------------------------------------------------------+
| 200 Ok           |                                                      |
+------------------+------------------------------------------------------+
| 404 not found    | If the video is not owned by the authenticated user. |
+------------------+------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)