Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This gem is a simple and easy to use wrapper for Instagram's API.
The documentation for this gem can be found at rdoc.info/gems/instagram_api.
Add this line to your application's Gemfile:
gem 'instagram_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install instagram_api
All methods in Instagram's API require some kind of authentication. You can retrieve any public data by using just your client ID, but it is recommended to authorize yourself (and your users) using an access_token. You can get your client ID and client secret by visiting http://instagram.com/developer.
# Instantiate a new client.
client = Instagram.client(
:client_id => '2bfe9d72a4aae8f06a31025b7536be80',
:client_secret => '9d667c2b7fae7a329f32b6df17926154',
:callback_url => 'http://example.com/'
)
# Visit the authorization URL in your browser and login.
client.authorize_url
# => "https://api.instagram.com/oauth/authorize/?client_id=2bfe9d72a4aae8f06a31025b7536be80&redirect_uri=http://example.com/&response_type=code"
# Retrieve the code from the URL parameters and use it to get an access token.
client.get_access_token('88fb89ab65454da2a06f2c6dacd09436')
# => '1313345.3fedf64.a0fcb7f40e02fe3da50500'
The last method, get_access_token
, will return your access token as well as set it for your client. You can then access any method in the API using your client.
Alternatively, after you or your user have authenticated, you can reinstantiate your client using the previously returned access token.
client = Instagram.client(:access_token => '1313345.3fedf64.a0fcb7f40e02fe3da50500')
You can access various information about Instagram users by using the following methods:
# Get a user information by id or username.
client.user(16500486)
client.user('caseyscarborough')
# Get the authenticated user's information.
client.user
# Search for a user by username.
client.search('github')
# Retrieve an authenticated user's feed.
client.feed
# Get a user's recent updates.
client.recent(16500486)
# Retrieve an authenticated user's updates.
client.recent
# Get an authenticated user's liked photos/videos.
client.liked
See the Instagram User Endpoints for more information.
You can retrieve media information by using the following methods:
# Get information about a media object by its ID.
client.media(42020)
# Search for a media item by latitude and longitude (required),
# with distance constraints (default 1000 meters).
client.media_search(:lat => "48.858844", :lng => "2.294351")
client.media_search(:lat => "48.858844", :lng => "2.294351", :distance => 2000)
# Search with Unix timestamp constraints.
client.media_search(
:lat => "48.858844",
:lng => "2.294351",
:min_timestamp => 1357020000,
:max_timestamp => 1375246800
)
# Get a list of popular media at the moment.
client.popular_media
See the Instagram Media Endpoints for more information.
The following is a sample application using this gem and Sinatra. Make sure that the sinatra and instagram_api gems are installed before running it.
$ gem install sinatra instagram_api
Afterwards, copy the contents of the following file into a file called sample.rb and add your client ID and client secret (retrieved by registering a new application at http://instagram.com/developer).
require 'sinatra'
require 'instagram_api'
# Go to http://instagram.com/developer to get your client ID and client secret.
CLIENT_ID = "YOUR CLIENT ID"
CLIENT_SECRET = "YOUR CLIENT SECRET"
# Set the redirect uri for your application to the following:
REDIRECT_URI = "http://localhost:4567/callback"
client = Instagram.client(
:client_id => CLIENT_ID,
:client_secret => CLIENT_SECRET,
:callback_url => REDIRECT_URI
)
get '/' do
output = '<h2>Popular Media</h2>'
client.popular_media.data.each do |p|
output << "<a href='#{p.link}'><img src='#{p.images.thumbnail.url}'></a> "
end
output << '<br /><h3><a href="/auth">Click here</a> to authenticate with Instagram.</h3>'
output
end
get '/auth' do
redirect client.authorize_url
end
get '/callback' do
client.get_access_token(params[:code])
redirect '/dashboard'
end
get '/dashboard' do
user = client.user
output = "<h2>#{user.data.username}'s feed</h2>"
client.feed.data.each do |f|
output << "<a href='#{f.link}'><img src='#{f.images.low_resolution.url}'></a><br />
<img src='#{f.user.profile_picture}' width='20'> #{f.user.username}<br /><br />"
end
output
end
You can then run the application by issuing the following command from the file's directory:
$ ruby sample.rb
Then navigate to localhost:4567 to see the application in action.
You can view/download this file here.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that instagram_api 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.