facebook API - batch requests to one request to get image dimensions - image

i am reading the whole public feed of an user with facebook graph api.
the way i get the feed is:
https://graph.facebook.com/userid/feed
so, in this feed sometimes there are posted pictures which i also want to use in my app. problem is:
when i just load the image source, i am getting a very low quality image.
with facebook graph api it is possible to get image dimensions when i have the object_id of the picture/photo like this:
https://graph.facebook.com/objectid?fields=images
with this call i am getting the image with all dimensions and imagesource URL.
but for this i have to call a request again. how can i batch that together so that i can get the feed WITH the imagesTAG directly in first call?
i have tried to call first and second level but i didnt get any solution:
https://graph.facebook.com/userid/feed?id,name,message,object_id,picture,type{images}
anyway, i tried so much but i cant get the image resolutions with ONE call in that json return.
is this not possible with the graph api? or what i am doing wrong here?
thanks,
brush51

Use this complex batch request to retrieve images (replace "me/home" with your request):
[{ "method":"GET","name":"me_home", "relative_url":"me/home?fields=object_id"}, { "method":"GET", "depends_on":"me_home", "relative_url":"?ids={result=me_home:$.data.*.object_id}"}]
But note that you will get only images hosted at Facebook.

Related

How to Fetch all images attached to a single facebook post?

I want to programmatically fetch all the images attached to a single facebook post. Is there a way to fetch all the images associated with a facebook post by using code? For eg i will pass the post url, and the images , lets say 10, all will get downloaded, or atleast capture their urls. Right now, the visible image url in the source code behind are only 4 images. The rest goes into a carousel on which we browse by clicking next.
for eg this fb post has over 47 images. in the main post, only the first 4 load. how do i get the rest of the images that are attached to this post
https://www.facebook.com/permalink.php?story_fbid=pfbid0qDrdWitZ8MG9Tr3nHLr9aY25TvKg6cEdYsULHDda9VsaJLQcFhHUJnauaqE9rrJwl&id=372414323284192

Parsing Youtube - Xpath to retrieve a Youtube Channel's Profile Picture and Description

I would like to import the profile picture of a number of Youtube Channels into a Google Sheets spreadsheet.
This is the information that I have been able to retrieve so far:
To retrieve the profile picture, I have used the following code using Social Blade's website:
=IMPORTXML(D2,"//img[#id='YouTubeUserTopInfoAvatar']")
However while it doesn't result in an erorr it doesn't retrieve the image from the src. Any idea how to make it work?
In regard to the description, I would like to use a code that can be consistently used using either the channel's id or Youtube's username. Other solutions that I have tried have allowed me to get a truncated description, not the full one.
Maybe there is a more cost-effective way of doing this task, but without much Javascript experience this is the easiest way I have found to retrieve the information. Ideally, I would like to find a solution that calls on the Youtube API and bypasses the 50-call limit.
Here's a sample Google Sheets template to work on a solution.
OK. I've edited your Google Sheet. You forgot the #src attribute for the image.
=IMAGE(IMPORTXML(E2;"//img[#id='YouTubeUserTopInfoAvatar']/#src"))
And I've added the XPath for the Youtube channel description (add "/about" at the end of the youtube channel links).
=IMPORTXML(C2,"//div[#class='about-description branded-page-box-padding']")
Note : You have to fix your "ChannelID" formula to extract the ID.

Do I need to request the Google-places-api every time a user views a page on my website to show an image?

I would like to use the google places api to show images on my website pages, in order to determine if we can use this I need to know the exact behavior of this call of the image. Does it mean that every time when a user enters a page to which I have attached the google places images functionality a call needs to be performed in order to show the image?
If so I can determine how much it would cost to make use of this functionality, hence page views are equal to api calls.
Thanks in advance
The Google Places Photos API has some pretty good documentation.
For each place you want photos for, you first have to make a request to Place Search or Place Details to retrieve a photos array. Each photo that you want to display would be another request through the api using your API Key and a photoreference from the photos array.
Both types of request could either be made from client side code or from your server. If made from your server, you could reduce the number of API calls made by caching photos arrays and photos for use across many web requests.

Pass an image get a list of URLs matching the image, HOW?

I'm essentially trying to do a reverse image search, i.e. I want to pass in an image and get back a results list of instances on the web where that image is found. I know Google's old API that did this is depreciated, I see some answers on SO (e.g. Google custom search for images only) that talk about doing an image search with Google's Custom Search API, but every time I dig into the code they are retrieving images from a string rather than what I'm trying to do. Is there currently any API that will help me with what I'm trying to do?
I'm sorry. I cannot write comments yet. How about this? https://github.com/tanaikech/goris
Recently, I found this. I don't know whether this is what you want.

Loading the first 5 images from google with specific keyword

I'm trying to load the first 5 image that comes up on google when I type a given keyword in my app. So let's say if the keyword was "Butter" I want to load the first 5 images that com up on google if you type butter.
I've been looking at the Github project SDWebImages (https://github.com/rs/SDWebImage), but it looks like you can only load the images if you have the url of the image.
Anybody know how I can do what I described, or anybody that can point me in the right direction as to what I should look at to do it.
Google has deprecated their image search API and you are now supposed to use custom search which supports images. You will need to sign up for an API key. When you make your search request you need to set your searchType parameter to image.

Resources