![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
instagram-community-maintained
Advanced tools
This project is a slight modification of the FB released and no longer maintained version of the gem. This addresses updated dependencies to allow for more recent versions of faraday and faraday middleware
A Ruby wrapper for the Instagram REST and Search APIs
gem install instagram
gem "instagram", git: 'https://github.com/GenomeUS/instagram-ruby-gem.git'
Our developer site documents all the Instagram REST and Search APIs.
The [Developer Blog] features news and important announcements about the Instagram Platform. You will also find tutorials and best practices to help you build great platform integrations. Make sure to subscribe to the RSS feed not to miss out on new posts: http://developers.instagram.com.
The Stack Overflow community is a great place to ask API related questions or if you need help with your code. Make sure to tag your questions with the Instagram tag to get fast answers from other fellow developers and members of the Instagram team.
Add it to the apps wiki!
require "sinatra"
require "instagram"
enable :sessions
CALLBACK_URL = "http://localhost:4567/oauth/callback"
Instagram.configure do |config|
config.client_id = "YOUR_CLIENT_ID"
config.client_secret = "YOUR_CLIENT_SECRET"
# For secured endpoints only
#config.client_ips = '<Comma separated list of IPs>'
end
get "/" do
'<a href="/oauth/connect">Connect with Instagram</a>'
end
get "/oauth/connect" do
redirect Instagram.authorize_url(:redirect_uri => CALLBACK_URL)
end
get "/oauth/callback" do
response = Instagram.get_access_token(params[:code], :redirect_uri => CALLBACK_URL)
session[:access_token] = response.access_token
redirect "/nav"
end
get "/nav" do
html =
"""
<h1>Ruby Instagram Gem Sample Application</h1>
<ol>
<li><a href='/user_recent_media'>User Recent Media</a> Calls user_recent_media - Get a list of a user's most recent media</li>
<li><a href='/user_media_feed'>User Media Feed</a> Calls user_media_feed - Get the currently authenticated user's media feed uses pagination</li>
<li><a href='/location_recent_media'>Location Recent Media</a> Calls location_recent_media - Get a list of recent media at a given location, in this case, the Instagram office</li>
<li><a href='/media_search'>Media Search</a> Calls media_search - Get a list of media close to a given latitude and longitude</li>
<li><a href='/media_popular'>Popular Media</a> Calls media_popular - Get a list of the overall most popular media items</li>
<li><a href='/user_search'>User Search</a> Calls user_search - Search for users on instagram, by name or username</li>
<li><a href='/location_search'>Location Search</a> Calls location_search - Search for a location by lat/lng</li>
<li><a href='/location_search_4square'>Location Search - 4Square</a> Calls location_search - Search for a location by Fousquare ID (v2)</li>
<li><a href='/tags'>Tags</a>Search for tags, view tag info and get media by tag</li>
<li><a href='/limits'>View Rate Limit and Remaining API calls</a>View remaining and ratelimit info.</li>
</ol>
"""
html
end
get "/user_recent_media" do
client = Instagram.client(:access_token => session[:access_token])
user = client.user
html = "<h1>#{user.username}'s recent media</h1>"
for media_item in client.user_recent_media
html << "<div style='float:left;'><img src='#{media_item.images.thumbnail.url}'><br/> <a href='/media_like/#{media_item.id}'>Like</a> <a href='/media_unlike/#{media_item.id}'>Un-Like</a> <br/>LikesCount=#{media_item.likes[:count]}</div>"
end
html
end
get '/media_like/:id' do
client = Instagram.client(:access_token => session[:access_token])
client.like_media("#{params[:id]}")
redirect "/user_recent_media"
end
get '/media_unlike/:id' do
client = Instagram.client(:access_token => session[:access_token])
client.unlike_media("#{params[:id]}")
redirect "/user_recent_media"
end
get "/user_media_feed" do
client = Instagram.client(:access_token => session[:access_token])
user = client.user
html = "<h1>#{user.username}'s media feed</h1>"
page_1 = client.user_media_feed(777)
page_2_max_id = page_1.pagination.next_max_id
page_2 = client.user_recent_media(777, :max_id => page_2_max_id ) unless page_2_max_id.nil?
html << "<h2>Page 1</h2><br/>"
for media_item in page_1
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html << "<h2>Page 2</h2><br/>"
for media_item in page_2
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
get "/location_recent_media" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Media from the Instagram Office</h1>"
for media_item in client.location_recent_media(514276)
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
get "/media_search" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Get a list of media close to a given latitude and longitude</h1>"
for media_item in client.media_search("37.7808851","-122.3948632")
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
get "/media_popular" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Get a list of the overall most popular media items</h1>"
for media_item in client.media_popular
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
get "/user_search" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Search for users on instagram, by name or usernames</h1>"
for user in client.user_search("instagram")
html << "<li> <img src='#{user.profile_picture}'> #{user.username} #{user.full_name}</li>"
end
html
end
get "/location_search" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Search for a location by lat/lng with a radius of 5000m</h1>"
for location in client.location_search("48.858844","2.294351","5000")
html << "<li> #{location.name} <a href='https://www.google.com/maps/preview/@#{location.latitude},#{location.longitude},19z'>Map</a></li>"
end
html
end
get "/location_search_4square" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Search for a location by Fousquare ID (v2)</h1>"
for location in client.location_search("3fd66200f964a520c5f11ee3")
html << "<li> #{location.name} <a href='https://www.google.com/maps/preview/@#{location.latitude},#{location.longitude},19z'>Map</a></li>"
end
html
end
get "/tags" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1>Search for tags, get tag info and get media by tag</h1>"
tags = client.tag_search('cat')
html << "<h2>Tag Name = #{tags[0].name}. Media Count = #{tags[0].media_count}. </h2><br/><br/>"
for media_item in client.tag_recent_media(tags[0].name)
html << "<img src='#{media_item.images.thumbnail.url}'>"
end
html
end
get "/limits" do
client = Instagram.client(:access_token => session[:access_token])
html = "<h1/>View API Rate Limit and calls remaining</h1>"
response = client.utils_raw_response
html << "Rate Limit = #{response.headers[:x_ratelimit_limit]}. <br/>Calls Remaining = #{response.headers[:x_ratelimit_remaining]}"
html
end
In the spirit of free software, everyone is encouraged to help improve this project.
Here are some ways you can contribute:
We use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issue by voting it up. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with failing specs.
Instagram has a bounty program for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
Contributor License Agreement ("CLA")
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Instagram's or Facebook's open source projects.
Complete your CLA here: https://code.facebook.com/cla
Copyright (c) 2014, Facebook, Inc. All rights reserved. By contributing to Instagram Ruby Gem, you agree that your contributions will be licensed under its BSD license. See LICENSE for details.
FAQs
Unknown package
We found that instagram-community-maintained demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.