Open guitmz opened 6 years ago
It seems like Instagram renamed a field for the Timeline endpoint.
https://github.com/ahmdrz/goinsta/blob/master/media.go#L656 the field items
is now called feed_items
. I changed this locally and it helped, the object is now populated. Its still empty though
here's the golang representation of the response body from Instagram timeline endpoint. my guess is that FeedItems
didn't had the MediaOrAd
nested struct before and it was implemented by Instagram recently.
type AutoGenerated struct {
NumResults int `json:"num_results"`
MoreAvailable bool `json:"more_available"`
AutoLoadMoreEnabled bool `json:"auto_load_more_enabled"`
FeedItems []struct {
MediaOrAd struct {
TakenAt int `json:"taken_at"`
Pk int64 `json:"pk"`
ID string `json:"id"`
DeviceTimestamp int64 `json:"device_timestamp"`
MediaType int `json:"media_type"`
Code string `json:"code"`
ClientCacheKey string `json:"client_cache_key"`
FilterType int `json:"filter_type"`
ImageVersions2 struct {
Candidates []struct {
Width int `json:"width"`
Height int `json:"height"`
URL string `json:"url"`
} `json:"candidates"`
} `json:"image_versions2"`
OriginalWidth int `json:"original_width"`
OriginalHeight int `json:"original_height"`
User struct {
Pk int `json:"pk"`
Username string `json:"username"`
FullName string `json:"full_name"`
IsPrivate bool `json:"is_private"`
ProfilePicURL string `json:"profile_pic_url"`
FriendshipStatus struct {
Following bool `json:"following"`
OutgoingRequest bool `json:"outgoing_request"`
IsMutingReel bool `json:"is_muting_reel"`
IsBestie bool `json:"is_bestie"`
} `json:"friendship_status"`
IsVerified bool `json:"is_verified"`
HasAnonymousProfilePicture bool `json:"has_anonymous_profile_picture"`
ReelAutoArchive string `json:"reel_auto_archive"`
IsUnpublished bool `json:"is_unpublished"`
IsFavorite bool `json:"is_favorite"`
} `json:"user"`
CanViewerReshare bool `json:"can_viewer_reshare"`
Caption struct {
Pk int64 `json:"pk"`
UserID int `json:"user_id"`
Text string `json:"text"`
Type int `json:"type"`
CreatedAt int `json:"created_at"`
CreatedAtUtc int `json:"created_at_utc"`
ContentType string `json:"content_type"`
Status string `json:"status"`
BitFlags int `json:"bit_flags"`
User struct {
Pk int `json:"pk"`
Username string `json:"username"`
FullName string `json:"full_name"`
IsPrivate bool `json:"is_private"`
ProfilePicURL string `json:"profile_pic_url"`
FriendshipStatus struct {
Following bool `json:"following"`
OutgoingRequest bool `json:"outgoing_request"`
IsMutingReel bool `json:"is_muting_reel"`
IsBestie bool `json:"is_bestie"`
} `json:"friendship_status"`
IsVerified bool `json:"is_verified"`
HasAnonymousProfilePicture bool `json:"has_anonymous_profile_picture"`
ReelAutoArchive string `json:"reel_auto_archive"`
IsUnpublished bool `json:"is_unpublished"`
IsFavorite bool `json:"is_favorite"`
} `json:"user"`
DidReportAsSpam bool `json:"did_report_as_spam"`
MediaID int64 `json:"media_id"`
} `json:"caption"`
CaptionIsEdited bool `json:"caption_is_edited"`
LikeCount int `json:"like_count"`
HasLiked bool `json:"has_liked"`
TopLikers []interface{} `json:"top_likers"`
CommentLikesEnabled bool `json:"comment_likes_enabled"`
CommentThreadingEnabled bool `json:"comment_threading_enabled"`
HasMoreComments bool `json:"has_more_comments"`
MaxNumVisiblePreviewComments int `json:"max_num_visible_preview_comments"`
PreviewComments []interface{} `json:"preview_comments"`
CanViewMorePreviewComments bool `json:"can_view_more_preview_comments"`
CommentCount int `json:"comment_count"`
InlineComposerDisplayCondition string `json:"inline_composer_display_condition"`
PhotoOfYou bool `json:"photo_of_you"`
CanViewerSave bool `json:"can_viewer_save"`
OrganicTrackingToken string `json:"organic_tracking_token"`
Preview string `json:"preview"`
InventorySource string `json:"inventory_source"`
IsSeen []bool `json:"is_seen"`
IsEOF bool `json:"is_eof"`
} `json:"media_or_ad"`
} `json:"feed_items"`
ClientGapEnforcerMatrix []struct {
List []int `json:"list"`
} `json:"client_gap_enforcer_matrix"`
IsDirectV2Enabled bool `json:"is_direct_v2_enabled"`
NextMaxID string `json:"next_max_id"`
ViewStateVersion string `json:"view_state_version"`
ClientFeedChangelistApplied bool `json:"client_feed_changelist_applied"`
Status string `json:"status"`
Messages []struct {
Time float64 `json:"time"`
Key string `json:"key"`
} `json:"_messages"`
}
Ok, I got a fix, in media.go
, updating https://github.com/ahmdrz/goinsta/blob/master/media.go#L656 to the code below works (there are more places that this need to be replaced, like the delete
/download
methods, etc).
Items []struct {
Media Item `json:"media_or_ad"`
} `json:"feed_items"`
I'm not opening a PR because Media
is a name I gave in my branch to fix this and I don't know how you handle this change, you can rework some things to fit this and there's probably a better (and less confusing) name.
I have this problem. And fix (https://github.com/ahmdrz/goinsta/blob/master/media.go#L656) don't work for me... I get empty result
@Highter87 something may have changed in the code since I opened this issue. For me it still works with code from July in my machine. Best for us is wait until someone sees this I guess
@guitmz, Yesterday analyzed the answers from Instagram, and found that the changes are not only in the structure of "FeedMedia", but even in "Item". Therefore json.Unmarshal does not work.
Ok I got the same with v2. However, the question - why goinsta v1 works fine for timeline???
Timeline.Get() is still not working?
Made a pull request to solve this issue https://github.com/ahmdrz/goinsta/pull/322
I ran the example at https://github.com/ahmdrz/goinsta/blob/master/examples/timeline/timeline.go and I get the following output (the output is the media object, printed with
fmt.Printf("%+v\n", media)
):No
Items
are returned. I tried with different loop sizes, they all come back empty.Timeline.Stories()
seems to be working well.EDIT: renaming issue