php - Get YouTube video uploader -
i've been searching on how youtube video's uploader , found had use youtube data v3 api.
the thing is: don't want use api key nor have kind of restrictions while performing queries. there way so?
yes, get_video_info available can read needed information it. there no official documentation it, though.
function parsequerystring($query) { $query = iconv(mb_detect_encoding($query, mb_detect_order(), true), "utf-8", $query); $params = explode('&', $query); $args = array(); foreach ($params $param) { $value = explode('=', $param); $args[$value[0]] = $value[1]; } return $args; } function getargs($args, $key, $query) { $iqs = strpos($args, $query); $querystring = ""; if ($iqs != -1) { $querystring = ($iqs < strlen($args) - 1) ? substr($args, $iqs + 1) : ""; $nvcargs = parsequerystring($querystring); return $nvcargs[$key]; } return ""; } function getvideouploader($url) { $id = getargs($url, "v", '?'); return getargs(file_get_contents("http://youtube.com/get_video_info?video_id=" . $id), "author", '&'); } the function getvideouploader first retrieves videoid input url , uses videoid video author (aka uploader). getargs function can used retrieving lot of other information youtube video , without need api key, such as: download link, length, title, thumbnail , more. getargs function needs output get_video_info in $args, parameter want find in $key , '&' symbol in $query.
you can list of parameters accessing http://youtube.com/get_video_info?video_id=injdpyoqt8u (as example), opening notepad++ , replacing '&' character '\n'.
Comments
Post a Comment