Youtube API get video query - php

I've been reading youtube API in orde to find how could I retrieve videos and relavant data about them using a certain query.
I've found this page - https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters
where there is an example of: https://gdata.youtube.com/feeds/api/videos?q=surfing&caption&v=2
My question is where should I use my API key ? I don't see any section for this in the query above.
Thanks.

For the v2 API, you only need your API key if you're uploading video.

Related

Duplicate video when upload via youtube api

I'm using Youtube API v3 to upload video. At the first time I use, it requires authorization then do upload but there are two videos is created. They are exactly the same but there is no error, the API returns the latest id. I checked in my channel, two videos could be view.
When I try to upload the previous video, another id returns, too, but if I use this, Youtube will show me "This video is a duplicate of another video". Other times, the API works right. Did anyone encounter this problem?

Can we know if we are streaming with youtube api?

i trying to know if my channel is streaming on youtube. I'm using the youtube api v3 with the php library.
I'm able to get the last broadcasts with liveBroadcasts.list but when I start streaming with OBS I put the parameters broadcastStatus = active and nothing is returned.
I also tried with liveStreams.list but I still get nothing. I don't know what I'm doing wrong, can someone explain me please ? :D
Try to use the search.list, Here you can set the optional parameters to search what you need. Like the channelId, eventType that you can set to live to include active broadcast, and type parameter that restricts a search query to only retrieve a particular type of resource.
Read the other parameters to know more about its purpose and description.
For more information you can also check this SO question:
Using YouTube API v3 to tell if a channel has a live stream
How to check if YouTube channel is streaming live
The request url is :
GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Csnippet%2Cstatus&mine=true&broadcastStatus=active&key={YOUR_API_KEY}
you should receive :
{"status":{ "lifeCycleStatus":"live"}}
You can use the search API - something like this:
https://www.googleapis.com/youtube/v3/search?part=id&channelId={CHANNEL_ID_YOU_WANT_TO_QUERY}&type=video&key={YOUR_API_KEY}&eventType=live
However, this might take 3-5 minutes before it shows the Video ID of broadcast video after the broadcast has started. This has been discussed in another StackOverflow Question: Using YouTube API v3 to tell if a channel has a live stream

Get youtube channel videos of particular channel using PHP Code

I want to display youtube videos for particular channel in XML format.
This is the channel for which I want to retrieve videos:
https://www.youtube.com/channel/UCxiaIKXjo25U1AMCBAcplRQ
can anyone suggest how can i get XML format video listing for particular channel from youtube.
I just want URL for which i can get what i want.
I can write PHP code to use XML retrieved from youtube API URL.
Here is the URL for API that you need to use for your purpose. hope it helps.
http://gdata.youtube.com/feeds/api/users/UCxiaIKXjo25U1AMCBAcplRQ/uploads?max-results=2

Youtube retrieve/embed

Is there a possible way where I can retrieve a list (with thumbnails) of my latest videos from youtube, store the embed code in a database using a cron job so I can show the video on a separate page instead of leading the users to youtube to view the videos? (all in php)
you can try to have a look at this page: https://developers.google.com/youtube/v3/
Google writes that:
You can use the API to fetch search results and to retrieve, insert, update, and delete resources like videos or playlists.
I saw thath PHP API are still in beta version but you can try it out. You must register your application to obtain credential to use API. At developers.google there is a lot of documentation and some examples (https://developers.google.com/youtube/v3/code_samples/php#retrieve_my_uploads)
Using API you don't need to retrieve code and store it into database, you can just show videos directly in your web application. I hope this is what you was looking for let me know if it helps!
Luca

Vimeo api to fetch videos by their uploaded date or title?

How can I fetch video using Vimeo API by their their or by their uploaded date?
Currently I am using vimeo.videos.getUploaded to fetch all the videos of a user but I am unable to pass parameters like title or date into that method call.
So please let me know how can I fetch videos of a user by video title or by uploaded date.
vimeo.video.getUploaded (and many other endpoints in the Vimeo API) allows you to provide a sort parameter of "oldest" or "newest".
You can experiment with this functionality via the playground :
https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded/playground

Categories