YouTube api v3 get video category - php

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.

Related

Search Google Shopping products PHP

Is it possible, using Google's API or merely faking a request to retrieve the products from a google shopping search query ? For example :
https://www.google.de/#tbm=shop&q=Samsung+Galaxy
I would like to retrieve all the results for the following query, trying to fake a request resulted me in an empty page as it seems like it makes a weird AJAX request to Google's API which I cannot parse.
Is there something similar to
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Samsung+Galaxy
for example ?
After doing a wide research I've seen that there is no API for google shopping - they closed it a while ago.
Therefore I used PhantomJS to render the whole page and then retrieve the data.

Is there on Instagram an official way to get photos according to hashtag but from ALL users and not only from the one related to the client id?

I know it's super easy to retrieve photos from Instagram according to a specific hashtag from your own profile (with the client id used in the connection to the library), but I could not find anything official to retrieve photos with an hashtag, independently by the users.
So, for instance, if my hashtag was test, an API grabbing a PHP object containing photos as in this link as in the following code
$o_instagram = new Instagram($s_client_id);
$o_media = $o_instagram->searchTags($s_hashtag);
Any ideas or suggestions? Thanks in advance.
have a look at the following endpoint
https://instagram.com/developer/endpoints/tags/#get_tags_media_recent
I'm not sure how it looks in their php library but in ruby is is something along the lines of Instagram_client.tag_recent_media(:tag)
It's paginated in order of most recent first

How can I get all the facebook page by category or subscribe on adding them?

For example: https://graph.facebook.com/181017065298015
Page has category, but I can't get category by FQL query like
SELECT categories FROM page WHERE name= "..."
This query return empty set
In the graph API I can subscribe for update only one page... But I need subscribe on adding any page with certain category! I don't found this in API.
There is a way to get this information by using API?
In other case direct me pls on operational metod
UPD:
Search page by graph API not allowed by page category, it works only for "name" field
https://graph.facebook.com/search?q=Games&type=page&access_token=...
There's a missmatch between the Graph API and FQL concerning the Page information available. The Graph API uses category, which is the "old" field, and FQL uses the newer categories. I think there's no way around this, one could consider this as a "flaw" in Facebooks API design.
Concerning your other question on "subscribing" (you mean liking I guess) all pages of certain category: This is NOT possible.

Facebook search

I am new to facebook api. I want to search for a particular word on facebook. I have gone through the documentation at https://developers.facebook.com/docs/reference/api/. But I dont know how to construct the query in PHP.
Could any one please provide a sample code. Also how do I specify the count and page (like twitter)?
I am currently using the API provided by facebook. I saw that there are alternative API's but I would like to restrict the API to the official one
Facebook provides the search functionality which is like searching using the search inside facebook.com.
To read about it go to here: http://developers.facebook.com/docs/reference/api/#searching
Edit
As it states in that document:
When searching for public posts or posts on the user's News Feed, you
can page over the results by using the since, until and limit
parameters. since and until both accept a unix timestamp.
Also, just a bit above the "searching" section there's the "Paging" section, using both you can come up with:
https://graph.facebook.com/search?q=coffee&type=place&offset=X&limit=4
Which in terms of using the php sdk, is probably like: "search?q=coffee&type=place&offset=X&limit=4"

Selecting specific fields with facebook graph api

I'd like to fetch statuses from users facebook newsfeed via the graph API.
It seems to be pretty simple when I have the right access token, then I can fetch this data with http://graph.facebook.com/home... But I want to fetch only statuses; no links, photos, videos and so on..
On the documentation page, I've seen many possibilities to specify selected data, for example I can limit obtained count of posts. Is there any possibility to control which data will be particularly fetched and which not? For example like graph.facebook.com/home?type="status"..
I can classify it in my PHP script, but then I need to be able to fetch a few more posts, like when I click on the more button on facebook or twitter, etc..I see some pagination data in Facebook JSON(I hope it's JSON:)), but I am propably not capable to use it in right way..
Thanks for your help!!
The doc page http://developers.facebook.com/docs/api says:
The Graph API allows you to read properties and connections of the Facebook social graph. You can use the API to read specific fields, get pictures of any object, introspect an object for metadata and get real-time updates on any changes.
...and...
You can choose the fields (or connections) you want returned with the "fields" query parameter. For example, this URL will only return the id, name, and picture of Ben: https://graph.facebook.com/bgolub?fields=id,name,picture

Categories