Find Videos by Tag
Updated: 2022-05-23 19:00:06
Interface URL
http://api.polyv.net/v2/video/{userid}/search
Interface Description
Find a list of videos by video tag
Supported Formats
XML/JSON
Request Method
POST, GET
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type & Scope | Description |
|---|---|---|---|
| userid | true | string | POLYV user ID, replace {userid} in http://api.polyv.net/v2/video/{userid}/search with the POLYV user ID value |
| format | false | string | Default returns json format, if format=xml returns xml format |
| jsonp | false | string | For example, normally returns {error:0,data:””}, adding jsonp=a returns a({error:0,data:””}) |
| numPerPage | false | int | Number per page |
| pageNum | false | int | Page number |
| ptime | true | string | Current time in milliseconds (13 digits), valid for 3 minutes |
| tag | false | string | Video tag |
| sign | true | string | Signature, a 40-character uppercase SHA1 value |
PHP Sample Code
<?php
$userid="9f1e0689e1";//必选
$format="";
$jsonp="";
$numPerPage=100;
$pageNum=1;
$ptime=time()*1000;//必选
$tag="刘诗昆";
$secretkey="AkDipaULWw";
$post_data = array (
"format" => $format,
"jsonp" => $jsonp,
"numPerPage" => $numPerPage,
"pageNum" => $pageNum,
"ptime" => $ptime,
"tag" => $tag
);
$str="";
foreach ($post_data as $key => $value){
if (!empty($value)) {
$str.=$key."=".$value."&";
}else{
unset($post_data[$key]);
}
}
$str=substr($str, 0,strlen($str)-1);
$str.=$secretkey;
// echo $str;
// die();
$hash=strtoupper(sha1($str));
$post_data["sign"] = $hash;
// var_dump($post_data);
// exit();
$url="http://api.polyv.net/v2/video/{$userid}/search";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
?>
Return Result
<xml>
<code>200</code>
<status>success</status>
<message>success</message>
<data>
<tag>刘诗昆,110435</tag>
<mp4>http://mpv.videocc.net/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_1.mp4</mp4>
<title>刘诗昆钢琴教程4</title>
<df>1</df>
<times>68</times>
<vid>9f1e0689e1a156fc6b373eab9195b0c6_9</vid>
<mp4_1>http://mpv.videocc.net/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_1.mp4</mp4_1>
<cataid>1470122811372</cataid>
<swf_link>http://player.polyv.net/videos/9f1e0689e1a156fc6b373eab9195b0c6_9.swf</swf_link>
<status>60</status>
<seed>0</seed>
<playerwidth>600</playerwidth>
<duration>00:35:52</duration>
<first_image>http://img.videocc.net/uimage/9/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_5.jpg</first_image>
<original_definition>384x294</original_definition>
<context></context>
<playerheight>458</playerheight>
<ptime>2016-04-28 12:11:10</ptime>
<source_filesize>65153042</source_filesize>
<filesize>69789952</filesize>
<md5checksum>b6dc8cd9ac9f189e5e2efeba8fd62d9b</md5checksum>
<hls>http://hls.videocc.net/9f1e0689e1/9/9f1e0689e1a156fc6b373eab9195b0c6_1.m3u8</hls>
</data>
</xml>
JSON Example
{
"code": 200,
"status": "success",
"message": "success",
"data": [
{
"tag": "刘诗昆,110435",
"mp4": "http://mpv.videocc.net/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_1.mp4",
"title": "刘诗昆钢琴教程4",
"df": 1,
"times": "68",
"vid": "9f1e0689e1a156fc6b373eab9195b0c6_9",
"mp4_1": "http://mpv.videocc.net/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_1.mp4",
"cataid": "1470122811372",
"swf_link": "http://player.polyv.net/videos/9f1e0689e1a156fc6b373eab9195b0c6_9.swf",
"status": "60",
"seed": 0,
"playerwidth": "600",
"duration": "00:35:52",
"first_image": "http://img.videocc.net/uimage/9/9f1e0689e1/6/9f1e0689e1a156fc6b373eab9195b0c6_5.jpg",
"original_definition": "384x294",
"context": "",
"playerheight": "458",
"ptime": "2016-04-28 12:11:10",
"source_filesize": 65153042,
"filesize": [
69789952
],
"md5checksum": "b6dc8cd9ac9f189e5e2efeba8fd62d9b",
"hls": [
"http://hls.videocc.net/9f1e0689e1/9/9f1e0689e1a156fc6b373eab9195b0c6_1.m3u8"
]
}
]
}
Field Description
| Field | Description |
|---|---|
| code | Return code |
| status | Return status |
| message | Return message |
| total | Total count |
| tag | Tag |
| mp4 | MP4 format video URL |
| title | Title |
| df | Video bitrate |
| times | Play count |
| vid | Video ID |
| mp4_1 | Smooth bitrate MP4 format video URL |
| cataid | Category ID, e.g., 1 for root directory |
| swf_link | Flash link |
| status | Video status |
| seed | 1 for encrypted video, 0 for non-encrypted |
| playerwidth | Video width |
| duration | Duration |
| first_image | Video thumbnail |
| original_definition | Best resolution |
| context | Video description |
| playerheight | Video height |
| ptime | Video upload date |
| source_filesize | Source file size |
| filesize | File size for each encoded clarity level, type is array |
| md5checksum | MD5 checksum |
| hls | M3U8 URL |
Sign Generation Rule
format=parameter&jsonp=parameter&numPerPage=parameter&pageNum=parameter&ptime=parameter&tag=parametersecureKey encrypted with SHA-1 and then converted to uppercase (Note: If a parameter is empty, it should not be included when generating the sign. For example, if there is no 't' here, do not append &t=parameter)
