Get youtube title from videoid in PHP using API v3
NickName:Saif Ask DateTime:2015-06-11T08:46:44

Get youtube title from videoid in PHP using API v3

Here is the url to to get the video info where you have to put VIDEO-ID and API-KEY:

https://www.googleapis.com/youtube/v3/videos?part=snippet&id=VIDEO-ID-HERE&key=YOUR-API-KEY-HERE

How to get the title from it and save it as a variable in PHP?

Copyright Notice:Content Author:「Saif」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769747/get-youtube-title-from-videoid-in-php-using-api-v3

Answers
theduck 2015-06-11T13:33:54

Something along these lines will get you the information related to a specific video using the PHP client library:\n\n<?php\n\nrequire_once 'Google/autoload.php';\nrequire_once 'Google/Client.php';\nrequire_once 'Google/Service/YouTube.php';\n\n$client = new Google_Client();\n$client->setDeveloperKey('{YOUR-API-KEY}');\n$youtube = new Google_Service_YouTube($client);\n\n$videoResponse = $youtube->videos->listVideos('snippet', array(\n 'id' => '{YOUR-VIDEO-ID}'\n));\n\n$title = $videoResponse['items'][0]['snippet']['title'];\n?>\n\n<!doctype html>\n<html>\n <head>\n <title>Video information</title>\n </head>\n <body>\n Title: <?= $title ?>\n </body>\n </html>\n\n\nOne more solution with API Request \n\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>\n<script>\n $(document).ready(function() {\n $.get(\n \"https://www.googleapis.com/youtube/v3/videos\",{\n part : 'snippet', \n id : 'VIODE_ID',\n key: 'API_KEY'},\n function(data) {\n $.each( data.items, function( i, item ) {\n alert(item.snippet.title);\n });\n }\n );\n}); \n</script>\n",


More about “Get youtube title from videoid in PHP using API v3” related questions

Get youtube title from videoid in PHP using API v3

Here is the url to to get the video info where you have to put VIDEO-ID and API-KEY: https://www.googleapis.com/youtube/v3/videos?part=snippet&amp;id=VIDEO-ID-HERE&amp;key=YOUR-API-KEY-HERE How t...

Show Detail

YouTube Channel Videos List in PHP with YouTube v3 API not Working

I am trying to fetch and display my YouTube channel videos using the YouTube v3 API. I have done the preliminary things like enabling YouTube v3 API in Google Developer console. I got this code som...

Show Detail

Get Youtube video data with API v3 JSON to PHP variables

I'm trying to migrate from the old API and I'm struggling to understand the new API v3. Basically I'm trying to make a PHP function that gets the video title, description, and statistics from the

Show Detail

remove videoid from youtube api output

Im using the youtube api to search for videos. My issue is that when a search is completed, the output from the search is video_name video_id I just want it to show video_name heres my code to

Show Detail

How to delete a video using the youtube API v3 and PHP

Just wondering how I would delete a video from YouTube using v3 of the API using the official Google PHP library. I see this here: Deleting a video from a playlist with YouTube Data API v3 $

Show Detail

How to retrieve details of single video from youtube using videoID through Data API v3.0 in Android?

My server sends the list of videoID to Android. Now, I want to show Title, Thumbnail and Number of Comments on these videos in List View. I have done this in web using GET request to https://www.

Show Detail

How to update the snippet.description on Youtube from Google Apps Script API using only the videoId?

I want to update my snippet.description on my Youtube channel using the API exposed through Google Apps Script. I know the videoId already so there is no need to create and loop through a search list

Show Detail

Allow users to upload videos to my channel using youtube API v3

Using Google API v3 php library . I want the user to upload videos on my youtube channel. But oAuth require user google login and the video uploaded to the logged in user youtube channel. Before u...

Show Detail

Need help getting the title from a video using jQuery (YouTube API v3)

So, I've recently came across learning how to use the YouTube API v3, and I've personally learned a lot from this API of theirs - What I'm wanting to know is how do I fetch the title of the video s...

Show Detail

How to get comments from videos using YouTube API v3 and Python?

I've been trying to get comments (both threads and replies) from a given video on YouTube using Python (as an exercise to learn the language). Based on the examples given at the official website (...

Show Detail