
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
A Ruby gem for publishing media to Instagram using Instagram Basic Display API and Instagram Graph API. This gem provides a simple interface to authenticate users via Instagram Login and publish images, videos, and carousel posts to their Instagram accounts.
Before using this gem, you need to:
Add this line to your application's Gemfile:
gem 'opossum'
And then execute:
bundle install
Or install it yourself as:
gem install oposum
This gem provides three independent classes for working with Instagram API:
require 'opossum'
# Create authenticator
authenticator = Opossum::Authenticator.new(
client_id: 'your_instagram_app_id',
client_secret: 'your_instagram_app_secret',
redirect_uri: 'your_redirect_uri'
)
# Get user info and long-lived token from authorization code
result = authenticator.get_user_info_from_code(
authorization_code,
fields: 'id,user_id'
)
# Returns:
# {
# access_token: {
# access_token: "ACCESS_TOKEN",
# token_type: "TOKEN_TYPE",
# expires_in: 5183742
# },
# user_details: {
# id: "IG_ID",
# user_id: "IG_USER_ID"
# }
# }
# Or get only long-lived token without user details
result = authenticator.get_user_info_from_code(authorization_code)
# Returns:
# {
# access_token: {
# access_token: "ACCESS_TOKEN",
# token_type: "TOKEN_TYPE",
# expires_in: 5183742
# }
# }
# If you need to refresh an existing access token
user_details = Opossum::UserDetails.new(
access_token: existing_access_token
)
# Refresh access token (extends for another 60 days)
refreshed_token = user_details.refresh_access_token
# Create publisher with access token and Instagram business account ID
publisher = Opossum::Publisher.new(
access_token: access_token,
ig_id: instagram_business_account_id
)
# Publish single image
result = publisher.publish_media(
media_url: 'https://example.com/image.jpg',
media_type: 'IMAGE'
)
# Publish image with caption
result = publisher.publish_media(
media_url: 'https://example.com/image.jpg',
media_type: 'IMAGE',
caption: 'Beautiful sunset! 🌅 #nature #photography'
)
# Publish carousel with caption
result = publisher.publish_media(
media_url: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg'
],
media_type: 'CAROUSEL',
caption: 'Photo collection from my trip ✈️ #travel #memories'
)
# That's it! publish_media handles everything automatically:
# - Creates media container(s)
# - Waits for processing to complete
# - Publishes the media
The gem includes comprehensive error handling for API responses with enhanced Instagram API error detection:
begin
publisher = Opossum::Publisher.new(
access_token: access_token,
ig_id: instagram_business_account_id
)
result = publisher.publish_media(
media_url: 'https://example.com/image.jpg'
)
rescue Opossum::Error => e
puts "Error: #{e.message}"
# Examples of error messages:
# "HTTP Error: Connection failed"
# "JSON Parse Error: Unexpected token"
# "Instagram API Error: Invalid media URL"
end
Error Handling Features:
error_message
fieldFeatures:
Note: Currently, carousel posts support only images. Support for mixed media types (images + videos) in carousels will be added in future versions.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/ninjarender/opossum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the OpossumInstagramPublisher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that opossum demonstrated a healthy version release cadence and project activity because the last version was released less than 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
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.