Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Timeline.Get() is not working properly #147

Open
guitmz opened this issue Jul 17, 2018 · 9 comments
Open

Timeline.Get() is not working properly #147

guitmz opened this issue Jul 17, 2018 · 9 comments

Comments

@guitmz
Copy link

guitmz commented Jul 17, 2018

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)):

&{inst:0xc4200fc0c0 err:<nil> uid:0 endpoint:feed/timeline/ timestamp: Items:[] NumResults:8 MoreAvailable:true AutoLoadMoreEnabled:true Status:ok NextID:BIG_NEXT_ID_HERE}
Next: BIG_NEXT_ID_HERE

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

@guitmz guitmz changed the title Timeline is not working (but user.Feed() works fine) Timeline is not working Jul 17, 2018
@guitmz guitmz changed the title Timeline is not working Timeline.Get() is not working properly Jul 17, 2018
@guitmz
Copy link
Author

guitmz commented Jul 17, 2018

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

@guitmz
Copy link
Author

guitmz commented Jul 17, 2018

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"`
}

@guitmz
Copy link
Author

guitmz commented Jul 17, 2018

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.

@0x000777
Copy link

0x000777 commented Aug 23, 2018

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

@guitmz
Copy link
Author

guitmz commented Aug 24, 2018

@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

@0x000777
Copy link

@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.

@inliquid
Copy link
Contributor

Ok I got the same with v2. However, the question - why goinsta v1 works fine for timeline???

@hmsta
Copy link

hmsta commented May 25, 2020

Timeline.Get() is still not working?

otono pushed a commit to otono/goinsta that referenced this issue Oct 8, 2020
@otono
Copy link

otono commented Oct 8, 2020

Made a pull request to solve this issue #322

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants