How to get dailymotion trending? - php

I am using below url to get Dailymotion trending videos, If i open the url in browser, it gives the correct data, but while scrapping the api using php, it gives me different results..
https://api.dailymotion.com/videos?fields=title&flags=no_live,no_premium&private=0&sort=trending&limit=20&country=in

With provided URL, it seems that DailyMotion API ignore the country parameter.
Fast reading API DOC, I understand that country parameter is used to set locale or as returned value.
To obtain language-filtered results, you can use language:
https://api.dailymotion.com/videos?fields=title&flags=no_live,no_premium&private=0&sort=trending&limit=20&language=in
This works for me.

Related

time range filter on ads endpoint (Facebook API)

We are trying to filter results of ads using date parameters on the /v2.7/{ad-account-id}/ads endpoint
According to the docs, you can use a time_range parameter, but it doesn't seem to be working properly using the PHP SDK or the graph explorer, example:
act_{1234456}/ads?time_range={'since':'2016-08-01','until':'2016-08-12'}
The documentation is pretty unclear on this because there is 2 references to the same ads endpoint but each with different params
https://developers.facebook.com/docs/marketing-api/reference/adgroup
https://developers.facebook.com/docs/marketing-api/reference/ad-account/ads/
Has anyone found a way to successfully filter by date/time range on the ads endpoint?
The right way to use the time_range param is as follows:
&time_range[since]=YYYY-MM-DD&time_range[until]=YYYY-MM-DD
make sure that square brackets are not url-encoded.

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

YouTube api v3 get video category

I'm working on a migration of the v2 implementation to v3, but I'm having some difficulty understanding how is API v3 segmented. I'm trying to get the video details from the API but for example, I'm unable to find where the video Category name is stored.
In the v2 implemetation I have:
$title = $info->entry->title->{'$t'};
$content = nl2br($info->entry->{'media$group'}->{'media$description'}->{'$t'});
and also
$info->entry->category
How would I translate this to the v3 implementation?
currently the api (v2) is quering this:
http://gdata.youtube.com/feeds/api/videos/
What is the v3 equivalent?
This is a PHP implementation btw.
thanks in advance
In V3, you don't query feeds, but instead query RESTful endpoints. So in your case, if you already know the videoIDs of the videos you want, you'll hit the videos->list endpoint, like this:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={comma separated list of video IDs}&key={YOUR_API_KEY}
The resultant json packet will have an 'items' list; each 'item' has a 'categoryId'.
Note that, to get details about the category ID itself, you can use the videoCategories->list endpoint, like this:
https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&id={comma separated list of ids}&key={YOUR_API_KEY}
The categories don't change all that often, so you can likely cache a lot of this data, but it is sometimes helpful to have your app keep up on the category details as that API also returns things like the auto-generated channel ID for the category, localized info (what the title of the category is in other languages and other regions), etc.
If you DON'T already have the videoIDs, you cannot use the videos->list endpoint, but instead must use the search->list endpoint. This gives you access to use lots of parameters to filter your search ... all are described here:
https://developers.google.com/youtube/v3/docs/search/list
The problem with this, however, is that the results of the search endpoint do NOT give you the categoryID, so currently you'd have to aggregate all the videoIDs from your search result and do a call to the videos->list endpoint with those ids to get the categories.

YouTube API PHP - Trouble retrieving full video description

I've been playing around with the google/google-api-php-client. I've noticed that it says "build-failing", but some parts are working as expected, so I've been pressing on with it.
So I have built a search field that queries the YouTube API for videos containing a search string and prints the results. You'll see that I've also hooked up the YouTube Player iFrame API to play the video if it is clicked.
Now these results do contain snippet data (title, description, channelId, etc...), but the item description's are limited to 160 characters and appended with an ellipsis ….
So now in an attempt to get a full description, I am sending another call to the YouTube API. I am calling $youtube->videos->listVideos('snippet',array('id' => '7dR02ebri9c')). The call is successful, but does not contain any snippet data.
I've logged the response to the console so you can see it here:
And printed it here incase the above image does not show.
{"etag":"\"43qFkeEQBKio26KDSq1ZQMzjhSo/3nlK0uyD_p1CFvvGkbiQcGORv5w\"","eventId":null,"kind":"youtube#videoListResponse","nextPageToken":null,"prevPageToken":null,"visitorId":null}
If I run the same request via the YouTube API Explorer, I receive a response complete with snippet data and a full description.
So I ask, is the problem the google/google-api-php-client I am using, the YouTube API itself, or perhaps something else?
Edit: I've found and thought about using madcoda/php-youtube-api instead, and will do-so if all else fails.
I've discovered that google/google-api-php-client was the problem here.
I've had success using madcoda/php-youtube-api instead.

Youtube API get video query

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.

Categories