我需要创建一个可以验证有效Vimeo视频的正则表达式。
根据Vimeo API,他们只使用视频ID的数字,但他们没有指定长度。
到目前为止我的正则表达式var regEx= /^[0-9]+$/;
我想知道: - vimeo视频ID支持的允许长度是多少? - 如何修改我的regEx?
答案 0 :(得分:2)
为什么不使用Vimeo developper API检查Vimeo ID是否有效,而不是尝试发明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. |
+------------------+--------------------------------------------------+
检查您(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. |
+------------------+------------------------------------------------------+