How can I get individual image_urls from an Instagram album using oembed api call? - instagram-api

I have been using the Instagram API to get images and videos, which works just fine. I then noticed the oembed API call, which does not require an access_token, and I decided to give that a try, which also worked just great as the thumbnail_url size is adequate for most uses.
However, I noticed that the images retrieved from an album, all have a thumbnail_url that returns a 5xx Error from Instagram.
My thinking is that:
a) This is exactly how it is supposed to work and if I want images from a gallery/album, I need to use the media API call and access_token like most normal people
b) There is a way to access all images from a gallery/album and I just don't know yet. What if I want to embed the album? If this is the case, how can I check if it is an album or single image before making an API call?
Here is what I have so far:
Instagram permalink for album/gallery: https://www.instagram.com/p/BTHpAmzDHKR/
OEMBED API call: https://api.instagram.com/oembed/?url=https%3A%2F%2Fwww.instagram.com%2Fp%2FBTHpAmzDHKR%2F
thumbnail_url returned: https://scontent-dft4-2.cdninstagram.com/t51.2885-15/s612x612/e35/18012162_1608580785827161_2716056344971968512_n.jpg
media API working url for same image:
https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/18012162_1608580785827161_2716056344971968512_n.jpg
This opens up to a 5xx Server Error
Is it possible or not using oembed call?
NOTE: I am trying this just out of curiosity and not for any real app.

Closing this out as my research has shown that oembed is for single media type only, not for carousel/albums. Instagram API call which uses tokens is required.

Related

Instagram Media/Feed API

I am currently looking at Instagram feed integration in a web app.
The offical APIs are: Instagram Graph API and Instagram Platform API.
And then I found one endpoint like https://www.instagram.com/instagram/media/ on SO, here and here, which seems an undocumented (at least I haven't seen it on facebook/instagram document).
It's publicly accessible and you can get a lot of information about the posts including likes and comments.
So my questions are:
Is the https://www.instagram.com/{username}/media/ documented some where?
Is it widely used on the internet?
Its not official API, it may stop working anytime, not a good idea to use in a App. Other Instagram undocumented APIs have stopped working in the past, its good to use for one-off projects but I would not use it in a app/website.
This endpoint has stopped working on November 7 2017. But you can use this other endpoint to get the same results:
GET /users/user-id/media/recent
https://api.instagram.com/v1/users/{user-id}/media/recent/?access_token=ACCESS-TOKEN
Get the most recent media published by a user.
The public_content scope is required if the user is not the owner of the access_token.
REQUIREMENTS
Scope: public_content
PARAMETERS
ACCESS_TOKEN A valid access token.
MAX_ID Return media earlier than this max_id.
MIN_ID Return media later than this min_id.
COUNT Count of media to return.
https://www.instagram.com/developer/endpoints/users/#get_users_media_recent
I wrote small library on typescript. It doesn't require access token or client id.The library uses RegExp under the hood. You can get your photos like this:
import Nanogram from 'nanogram.js';
const instagramParser = new Nanogram();
instagramParser.getMediaByUsername('instagram').then((media) => {
console.log(media);
});

How to post an online image to Twitter using NodeJS?

I am trying to post an online image (eg. https://cdn.pulselive.com/test/client/pl/dev/i/default-thumbnails/t8.png) using NodeJS and Twitter API. I have used Twit for the development, but I am not sure how to put the media type for the image. Currently, since I havent specified the media type, it is leading to an error that says please specify the type of an image.

Retrieve BLOGS_UPLOADED_IMAGES in java

I have some java code that retrieves blogs through the REST API's. I am not using the social business toolkit, but we have our own framework for that.
The application works perfectly on an on-premise connections environment and has worked on multiple versions.
However when switching to Connections Cloud, some parts stopped worked.
We get a 403 - Forbidden exception on 2 occasions:
Getting the details of a blog post: /blogs/[blog-id]/feed/entry/atom?entryid=[entry-id]
Getting images inside the blog post: /blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image file name]
I have fixed issue 1) by switching to the plublishing API: /blogs/[blog-id]/api/entries/[entry-id].
I cannot find a way to fix issue 2). I have also found 2 other image urls:
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/[file-name]
https://apps.ce.collabserv.com/blogs/[blog-id]/api/media/BLOGS_UPLOADED_IMAGES/[file-name].media
Both return:
<sp_0:error xmlns="http://incubator.apache.org/abdera" xmlns:sp_0="http://incubator.apache.org/abdera">
<code>404</code>
<message>Not Found</message>
</sp_0:error>
I want to authenticate by using Basic Authentication when possible. This does not appear to work with the given 403 urls.
My guess is that this the basic authentication header is not picked up. I have seen this before.
I used to fix this by first calling another URL that does support basic authentication and using the Ltpa cookies to authenticate the image url.
This also does not work: I do get LtpaTokens, but when I pass all the cookies to the URL, the image still does not work.
I prefer not to use OAuth of OAuth 2 at this moment. Is there any other way to fix this?
Anybody else managed to retrieve BLOGS_UPLOADED_IMAGES?
The issue is can also be reproduced in a browser.
Make sure you are not yet authenticated and the blog has posts with
images
Go to /blogs/[blog-id]/api/media
Authenticate using the popup in the browser The Atom feed now appears. This contains the images of your blog.
403 when opening:
/blogs/[blog-id]/resource/BLOGS_UPLOADED_IMAGES/[image]
404 xml when opening: /blogs/[blog-id]/api/media/* links

Instagram API get most recent images around the world

I am using the Instagram API to fetch photos not tagged with a certain hashtag or from a certain location. I just like to fetch constantly the most recent uploaded images around the world.
How can I do that?
use this api url
https://api.instagram.com/v1/media/popular?access_token=ACCESS-TOKEN
will be got response in json format.it would contains all most media like image, video. if you want images only from this response data you can parser only image data from this response data using field 'type:image'

Grab instagram photo based on hashtags

I am new to instagram and i am tasked to program an application to grab instagram photo uploads based on a certain hashtag. Meaning if the application is started and searching for the hashtag "#awesomeevent" any one that uploads a photo with that hashtags it will automatically be stored into our database.
The application should work something similar to http://statigr.am/tag/ but instead displaying the photos it should store the photos into the database.
What is the process of doing this. Any tutorials that has this from start to end. Even covering how to start creating a instagram app from scratch. any help would be greatly appreciated.
Thanks
Things we developers often overlook are the API Terms and Conditions. I've been there myself.
API TERMS OF USE
Before you start using the API, we have a few guidelines that we'd like to tell you about. Please make sure to read the full API Terms of Use
Terms of Use. Here's what you'll read about:
Instagram users own their images. It's your responsibility to make sure that you respect that right.
You cannot use the Instagram name in your application.
You cannot use the Instagram API to crawl or store users' images without their express consent.
You cannot replicate the core user experience of Instagram.com
Do not abuse the API. Too many requests too quickly will get your access turned off
However, a part in the terms also states that:
You shall not cache or store any Instagram user photos other than for reasonable periods in order to provide the service you are
providing to Instagram users.
Hope that's a start before you actually get coding and storing images.
API Terms of Use: http://instagram.com/about/legal/terms/api/
API: http://instagram.com/developer/
For starter, you should consult to instagram api.
As for the specific api you will need is:
/tags/tag-name/media/recent
For example, if you want to look for images from tag #awesomeevent, you will do an api query to:
https://api.instagram.com/v1/tags/awesomeevent/media/recent?access_token=ACCESS-TOKEN
I would have a look at the two libraries Instagram provides. The ruby library is at https://github.com/Instagram/instagram-ruby-gem and the python library is at https://github.com/Instagram/python-instagram
They both seem to have examples to get you started if you're programming with either libraries.
As far as the storing issue goes, could you instead store the URL address of the images instead of the actual images themselves? The API returns JSON information of which the URL of the images are returned.
Hope that helps.
You can use the below ruby script to retrieve the images and save them to a file. You can then either reference the file within the database or replace the last block with code for your particular database implementation. Without knowing your database type and schema, no one can tell you how to add something to it.
require "instagram"
require "restclient"
Instagram.configure do |config|
config.client_id = INSTAGRAM_CLIENT_ID
config.client_secret = INSTAGRAM_CLIENT_SECRET
end
instagram_client = Instagram.client(:access_token => INSTAGRAM_ACCESS_TOKEN)
tags = instagram_client.tag_search('cat')
urls = Array.new
for media_item in instagram_client.tag_recent_media(tags[0].name)
urls << media_item.images.standard_resolution.url
end
urls.each_with_index do |url, idx|
image = RestClient.get(url)
path = Dir.pwd + "/#{idx}.jpg"
File.open(path, 'w') {|f| f.write(image) }
end

Resources