php - json for displaying youtube video description and view count is not working after a youtube update -


i have facebook wall, in project, when user posts youtube link, displayed in facebook wall. first image , description , views. code used work sucessfully, after update @ youtube, there bugs, image displayed sucessfully not title, description , views. ideas how fix this? code getting title, video description , views count:

<?php  $find_youtube = "://www.youtube.com/";  if(preg_match('~msie|internet explorer~i', $_server['http_user_agent'])) {   if(preg_match("[$find_youtube]", $row['comment'])){    parse_str( parse_url( $row['comment'], php_url_query ), $my_array_of_vars );    $regex='#(?<=v=)[a-za-z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n ]+#';   preg_match($regex, $row['comment'], $mid);    $id = $mid[0];    $json_output = file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?v=2&alt=json");   $json = json_decode($json_output, true);   $video_title = $json['entry']['title']['$t'];   $video_description = $json['entry']['media$group']['media$description']['$t'];   $view_count = $json['entry']['yt$statistics']['viewcount'];   $video_perigrafh = substr($video_description , 0, 160);    } }  ?> 

you can call video.list() method of v3 api video resource associated details. check following link:

https://developers.google.com/youtube/v3/docs/videos

$json_output = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$id}&part=snippet,statistics&alt=json"); $json = json_decode($json_output, true); $video_title = $json['entry']['snippet']['title']; $video_description = $json['entry']['snippet']['description']; $view_count = $json['entry']['statistics']['viewcount']; $video_perigrafh = substr($video_description , 0, 160); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -