opossum 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +11 -4
- data/lib/opossum/api_helper.rb +1 -1
- data/lib/opossum/publisher.rb +19 -13
- data/lib/opossum/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 721a81517304c17e172662c5fbd1e055dd3d218658749d04efd02191cb866eb6
|
|
4
|
+
data.tar.gz: 006cdb6681a963740d03d62dd566f2a3323027556dacc8591afc6c3e8732fcc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23a6aa7fe4861ca4c62eb3a293fe4d507c2b33d479253b1340cddf561f97a43827170fa29d4b7a8f3db2b72fc739a3423fea49645d88ede37f0b443e5fd47170
|
|
7
|
+
data.tar.gz: 7ce15a3f0382aa0b57671c6aa62fc53f1dec2c214e52a90bfec640f2ef2d8fb209d64d42c26abc5f28d2bbc01090979f6ca25136078e0d6a3772fd55ba3402cb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [0.4.0] - 2026-10-06
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
- **Image stories** - `Publisher#publish_media` accepts `media_format: "IMAGE" | "VIDEO"` for `media_type: "STORIES"`
|
|
5
|
+
- `"IMAGE"` sends the media URL as `image_url`; `"VIDEO"` (and the default, unchanged) as `video_url`
|
|
6
|
+
- Other media types ignore `media_format`
|
|
7
|
+
|
|
8
|
+
## [0.3.1] - 2025-01-27
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **API Error Handling** - Improved error handling in ApiHelper
|
|
12
|
+
- Enhanced error message extraction with fallback to nested error structure
|
|
13
|
+
|
|
1
14
|
## [0.3.0] - 2025-08-12
|
|
2
15
|
|
|
3
16
|
### Improved
|
|
@@ -66,7 +79,7 @@
|
|
|
66
79
|
### Added
|
|
67
80
|
|
|
68
81
|
#### Core Architecture
|
|
69
|
-
- **Authenticator class** - OAuth authentication with Instagram
|
|
82
|
+
- **Authenticator class** - OAuth authentication with Instagram API with Instagram Login
|
|
70
83
|
- Exchange authorization code for access token
|
|
71
84
|
- Support for client credentials and redirect URI configuration
|
|
72
85
|
|
data/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# OpossumInstagramPublisher
|
|
2
2
|
|
|
3
|
-
A Ruby gem for publishing media to Instagram using Instagram
|
|
3
|
+
A Ruby gem for publishing media to Instagram using Instagram API with Instagram Login. This gem provides a simple interface to authenticate users via Instagram Login and publish images, videos, and carousel posts to their Instagram accounts.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
7
|
Before using this gem, you need to:
|
|
8
8
|
|
|
9
|
-
1. Create a Facebook App and configure Instagram
|
|
10
|
-
2. Set up Instagram
|
|
9
|
+
1. Create a Facebook App and configure Instagram API with Instagram Login
|
|
10
|
+
2. Set up Instagram API with Instagram Login permissions
|
|
11
11
|
3. Configure OAuth redirect URIs in your Facebook App settings
|
|
12
12
|
4. Obtain your Instagram Business Account ID
|
|
13
13
|
|
|
@@ -121,6 +121,13 @@ result = publisher.publish_media(
|
|
|
121
121
|
caption: 'Photo collection from my trip ✈️ #travel #memories'
|
|
122
122
|
)
|
|
123
123
|
|
|
124
|
+
# Publish a story (media_format picks image_url vs video_url; default is VIDEO)
|
|
125
|
+
result = publisher.publish_media(
|
|
126
|
+
media_url: 'https://example.com/story.jpg',
|
|
127
|
+
media_type: 'STORIES',
|
|
128
|
+
media_format: 'IMAGE'
|
|
129
|
+
)
|
|
130
|
+
|
|
124
131
|
# That's it! publish_media handles everything automatically:
|
|
125
132
|
# - Creates media container(s)
|
|
126
133
|
# - Waits for processing to complete
|
|
@@ -163,7 +170,7 @@ end
|
|
|
163
170
|
- **IMAGE** - Single images (JPEG, PNG) with optional caption
|
|
164
171
|
- **VIDEO** - Single videos (MP4, MOV) with optional caption
|
|
165
172
|
- **REELS** - Instagram Reels with optional caption
|
|
166
|
-
- **STORIES** - Instagram Stories
|
|
173
|
+
- **STORIES** - Instagram Stories; pass `media_format: 'IMAGE'` or `'VIDEO'` (default) to choose the URL field
|
|
167
174
|
- **CAROUSEL** - Multiple images in a single post with optional caption (automatically handled when passing an array of URLs)
|
|
168
175
|
|
|
169
176
|
**Features:**
|
data/lib/opossum/api_helper.rb
CHANGED
|
@@ -57,7 +57,7 @@ module Opossum
|
|
|
57
57
|
raise Opossum::Error.new(
|
|
58
58
|
"Instagram API Error: #{error_message}",
|
|
59
59
|
code: parsed_response.dig("error", "code"),
|
|
60
|
-
subcode: parsed_response.dig("error", "subcode")
|
|
60
|
+
subcode: parsed_response.dig("error", "subcode") || parsed_response.dig("error", "error_subcode")
|
|
61
61
|
)
|
|
62
62
|
end
|
|
63
63
|
end
|
data/lib/opossum/publisher.rb
CHANGED
|
@@ -12,9 +12,12 @@ module Opossum
|
|
|
12
12
|
@ig_id = ig_id
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# media_format applies to STORIES only: "IMAGE" sends the url as image_url,
|
|
16
|
+
# "VIDEO" (the default) as video_url. Other media types ignore it.
|
|
17
|
+
def publish_media(media_url:, media_type: "IMAGE", caption: nil, media_format: nil)
|
|
16
18
|
path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media_publish"
|
|
17
|
-
media_container_id = prepare_media_container(media_url: media_url, media_type: media_type, caption: caption
|
|
19
|
+
media_container_id = prepare_media_container(media_url: media_url, media_type: media_type, caption: caption,
|
|
20
|
+
media_format: media_format)
|
|
18
21
|
|
|
19
22
|
ApiHelper.post(
|
|
20
23
|
path: path,
|
|
@@ -26,11 +29,12 @@ module Opossum
|
|
|
26
29
|
|
|
27
30
|
attr_reader :ig_id
|
|
28
31
|
|
|
29
|
-
def prepare_media_container(media_url:, media_type:, caption:)
|
|
32
|
+
def prepare_media_container(media_url:, media_type:, caption:, media_format: nil)
|
|
30
33
|
if media_url.is_a?(Array)
|
|
31
34
|
prepare_carousel_media(media_urls: media_url, media_type: media_type, caption: caption)
|
|
32
35
|
else
|
|
33
|
-
create_media_container(media_url: media_url, media_type: media_type, caption: caption
|
|
36
|
+
create_media_container(media_url: media_url, media_type: media_type, caption: caption,
|
|
37
|
+
media_format: media_format)
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
|
|
@@ -46,10 +50,10 @@ module Opossum
|
|
|
46
50
|
create_media_container(media_url: children_ids, media_type: media_type, caption: caption)
|
|
47
51
|
end
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
# options: is_carousel_item:, upload_type:, media_format:
|
|
54
|
+
def create_media_container(media_url:, media_type: "IMAGE", caption: nil, **options)
|
|
50
55
|
path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media"
|
|
51
|
-
body = build_media_container_body(media_url: media_url, media_type: media_type, caption: caption,
|
|
52
|
-
is_carousel_item: is_carousel_item, upload_type: upload_type)
|
|
56
|
+
body = build_media_container_body(media_url: media_url, media_type: media_type, caption: caption, **options)
|
|
53
57
|
|
|
54
58
|
response = ApiHelper.post(path: path, body: body)
|
|
55
59
|
media_container_id = response["id"]
|
|
@@ -58,20 +62,22 @@ module Opossum
|
|
|
58
62
|
media_container_id
|
|
59
63
|
end
|
|
60
64
|
|
|
61
|
-
def build_media_container_body(media_url:, media_type:, caption:,
|
|
65
|
+
def build_media_container_body(media_url:, media_type:, caption:, **options)
|
|
62
66
|
body = { access_token: access_token, media_type: media_type, caption: caption }
|
|
63
|
-
set_media_url_field(body, media_url, media_type)
|
|
64
|
-
body[:is_carousel_item] = is_carousel_item if is_carousel_item
|
|
65
|
-
body[:upload_type] = upload_type if upload_type
|
|
67
|
+
set_media_url_field(body, media_url, media_type, options[:media_format])
|
|
68
|
+
body[:is_carousel_item] = options[:is_carousel_item] if options[:is_carousel_item]
|
|
69
|
+
body[:upload_type] = options[:upload_type] if options[:upload_type]
|
|
66
70
|
body
|
|
67
71
|
end
|
|
68
72
|
|
|
69
|
-
def set_media_url_field(body, media_url, media_type)
|
|
73
|
+
def set_media_url_field(body, media_url, media_type, media_format = nil)
|
|
70
74
|
case media_type
|
|
71
75
|
when "IMAGE"
|
|
72
76
|
body[:image_url] = media_url
|
|
73
|
-
when "VIDEO", "REELS"
|
|
77
|
+
when "VIDEO", "REELS"
|
|
74
78
|
body[:video_url] = media_url
|
|
79
|
+
when "STORIES"
|
|
80
|
+
body[media_format.to_s.upcase == "IMAGE" ? :image_url : :video_url] = media_url
|
|
75
81
|
when "CAROUSEL"
|
|
76
82
|
body[:children] = media_url
|
|
77
83
|
end
|
data/lib/opossum/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opossum
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vadym Kruchyna
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -133,6 +133,6 @@ requirements: []
|
|
|
133
133
|
rubygems_version: 3.5.22
|
|
134
134
|
signing_key:
|
|
135
135
|
specification_version: 4
|
|
136
|
-
summary: Ruby gem for publishing media to Instagram using Instagram
|
|
137
|
-
|
|
136
|
+
summary: Ruby gem for publishing media to Instagram using Instagram API with Instagram
|
|
137
|
+
Login
|
|
138
138
|
test_files: []
|