instabot

package
v0.0.0-...-09ac254 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_URL = "https://i.instagram.com/api/v1/"

	//TODO: Find out the way to configure this stuff
	ANDROID_VERSION = "19"    //Android.os.Build.VERSION.SDK_INT
	ANDROID_RELEASE = "4.4.2" //Android.os.Build.VERSION.RELEASE
	DPI             = "240dpi"
	RESOLUTION      = "480x800"
	MANUFACTURER    = "FLY"    //Android.os.Build.MANUFACTURER
	MODEL           = "IQ4418" //Android.os.Build.MODEL
	DEVICE          = "IQ4418" //Android.os.Build.DEVICE
	HARDWARE        = "mt6572" //Android.os.Build.HARDWARE
	LOCALE          = "ru_RU"
	VERSION         = "9.2.0" // I'm not sure which value I should pick

	USER_AGENT      = "Instagram " + VERSION + " Android (" + ANDROID_VERSION + "/" + ANDROID_RELEASE + "; " + DPI + "; " + RESOLUTION + "; " + MANUFACTURER + "; " + MODEL + "; " + DEVICE + "; " + HARDWARE + "; " + LOCALE + ")"
	IG_SIG_KEY      = "012a54f51c49aa8c5c322416ab1410909add32c966bbaa0fe3dc58ac43fd7ede"
	EXPERIMENTS     = "" /* 3656-byte string literal not displayed */
	SIG_KEY_VERSION = "4"
)

Variables

View Source
var HEADERS = map[string]string{
	"Connection":      "close",
	"Accept":          "*/*",
	"Content-type":    "application/x-www-form-urlencoded; charset=UTF-8",
	"Cookie2":         "$Version=1",
	"Accept-Language": "en-US",
	"User-Agent":      USER_AGENT,
}
View Source
var JAR_URL = buildJarUrl()

Functions

This section is empty.

Types

type Client

type Client struct {
	PK           int
	Username     string
	Password     string
	Seed         string
	DeviceId     string
	GUUID        string
	Token        string
	RankToken    string
	Suspected    bool
	LastResponse []byte
	LoggedAt     time.Time
	Cookies      []*http.Cookie
}

func Login

func Login(username string, password string) (*Client, error)

func (*Client) Comment

func (c *Client) Comment(mediaPk int, text string) (*CommentResponse, error)

func (*Client) Follow

func (c *Client) Follow(pk int) (*FollowResponse, error)

func (*Client) GetHashtagFeed

func (c *Client) GetHashtagFeed(hashtag string, maxid string) (*GetHashtagFeedResponse, error)

func (*Client) GetMediaComments

func (c *Client) GetMediaComments(mediaPk int, maxid string) (*GetMediaCommentsResponse, error)

func (*Client) GetMediaLikers

func (c *Client) GetMediaLikers(mediaPk int, maxid string) (*GetMediaLikersResponse, error)

func (*Client) GetTotalUserFollowers

func (c *Client) GetTotalUserFollowers(pk int) (map[int]bool, error)

There is ids map for faster processing

func (*Client) GetTotalUserFollowings

func (c *Client) GetTotalUserFollowings(pk int) (map[int]bool, error)

func (*Client) GetUserFeed

func (c *Client) GetUserFeed(pk int, maxid string, minTimestamp int64) (*GetUserFeedResponse, error)

func (*Client) GetUserFollowers

func (c *Client) GetUserFollowers(pk int, maxid string) (*GetUserFollowersResponse, error)

func (*Client) GetUserFollowings

func (c *Client) GetUserFollowings(pk int, maxid string) (*GetUserFollowingsResponse, error)

func (*Client) Init

func (c *Client) Init(username string, password string, cookies []*http.Cookie)

func (*Client) Like

func (c *Client) Like(mediaId int) (*LikeResponse, error)

func (*Client) Login

func (c *Client) Login() (*LoginResponse, error)

func (*Client) SearchUsername

func (c *Client) SearchUsername(username string) (*SearchUsernameResponse, error)

func (*Client) Unfollow

func (c *Client) Unfollow(pk int) (*UnfollowResponse, error)

type CommentResponse

type CommentResponse struct {
	Comment struct {
		ContentType  string  `json:"content_type"`
		User         *User   `json:"user"`
		Pk           int     `json:"pk"`
		Text         string  `json:"text"`
		Type         int     `json:"type"`
		CreatedAt    float64 `json:"created_at"`
		CreatedAtUtc int     `json:"created_at_utc"`
		MediaID      int64   `json:"media_id"`
		Status       string  `json:"status"`
	} `json:"comment"`
	Status string `json:"status"`
}

type FollowResponse

type FollowResponse struct {
	*FriendshipStatus `json:"friendship_status"`
	Status            string `json:"status"`
}

type FriendshipStatus

type FriendshipStatus struct {
	IncomingRequest bool `json:"incoming_request"`
	IsPrivate       bool `json:"is_private"`
	Following       bool `json:"following"`
	OutgoingRequest bool `json:"outgoing_request"`
	FollowedBy      bool `json:"followed_by"`
	Blocking        bool `json:"blocking"`
}

type GetHashtagFeedResponse

type GetHashtagFeedResponse struct {
	Items               []*HashtagItem `json:"items"`
	NumResults          int            `json:"num_results"`
	NextMaxID           string         `json:"next_max_id"`
	MoreAvailable       bool           `json:"more_available"`
	AutoLoadMoreEnabled bool           `json:"auto_load_more_enabled"`
	Status              string         `json:"status"`
}

type GetMediaCommentsResponse

type GetMediaCommentsResponse struct {
	CommentLikesEnabled bool `json:"comment_likes_enabled"`
	Comments            []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             *User  `json:"user"`
		HasLikedComment  bool   `json:"has_liked_comment"`
		CommentLikeCount int    `json:"comment_like_count"`
	} `json:"comments"`
	CommentCount int `json:"comment_count"`
	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         *User  `json:"user"`
	} `json:"caption"`
	CaptionIsEdited         bool `json:"caption_is_edited"`
	HasMoreComments         bool `json:"has_more_comments"`
	HasMoreHeadloadComments bool `json:"has_more_headload_comments"`
	PreviewComments         []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         *User  `json:"user"`
	} `json:"preview_comments"`
	NextMaxID string `json:"next_max_id"`
	Status    string `json:"status"`
}

type GetMediaLikersResponse

type GetMediaLikersResponse struct {
	Users     []*User `json:"users"`
	UserCount int     `json:"user_count"`
	Status    string  `json:"status"`
}

type GetUserFeedResponse

type GetUserFeedResponse struct {
	Items               []*Item `json:"items"`
	NumResults          int     `json:"num_results"`
	MoreAvailable       bool    `json:"more_available"`
	NextMaxID           string  `json:"next_max_id"`
	AutoLoadMoreEnabled bool    `json:"auto_load_more_enabled"`
	Status              string  `json:"status"`
}

type GetUserFollowersResponse

type GetUserFollowersResponse struct {
	Users     []*User `json:"users"`
	BigList   bool    `json:"big_list"`
	PageSize  int     `json:"page_size"`
	NextMaxID string  `json:"next_max_id"`
	Status    string  `json:"status"`
}

type GetUserFollowingsResponse

type GetUserFollowingsResponse struct {
	Users     []*User `json:"users"`
	BigList   bool    `json:"big_list"`
	PageSize  int     `json:"page_size"`
	NextMaxID string  `json:"next_max_id"`
	Status    string  `json:"status"`
}

type HashtagItem

type HashtagItem struct {
	TakenAt         int    `json:"taken_at"`
	PK              int    `json:"pk"`
	ID              string `json:"id"`
	DeviceTimestamp int    `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                         *User         `json:"user"`
	OrganicTrackingToken         string        `json:"organic_tracking_token"`
	LikeCount                    int           `json:"like_count"`
	HasLiked                     bool          `json:"has_liked"`
	CommentLikesEnabled          bool          `json:"comment_likes_enabled"`
	HasMoreComments              bool          `json:"has_more_comments"`
	MaxNumVisiblePreviewComments int           `json:"max_num_visible_preview_comments"`
	PreviewComments              []interface{} `json:"preview_comments"`
	Comments                     []interface{} `json:"comments"`
	CommentCount                 int           `json:"comment_count"`
	Caption                      struct {
		Pk           int64  `json:"pk"`
		UserID       int64  `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         *User  `json:"user"`
		MediaID      int64  `json:"media_id"`
	} `json:"caption"`
	CaptionIsEdited bool  `json:"caption_is_edited"`
	PhotoOfYou      bool  `json:"photo_of_you"`
	NextMaxID       int64 `json:"next_max_id,omitempty"`
	Usertags        struct {
		In []interface{} `json:"in"`
	} `json:"usertags,omitempty"`
}

type Item

type Item struct {
	TakenAt         int    `json:"taken_at"`
	PK              int    `json:"pk"`
	ID              string `json:"id"`
	DeviceTimestamp int    `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                         *User         `json:"user"`
	OrganicTrackingToken         string        `json:"organic_tracking_token"`
	LikeCount                    int           `json:"like_count"`
	TopLikers                    []interface{} `json:"top_likers"`
	HasLiked                     bool          `json:"has_liked"`
	CommentLikesEnabled          bool          `json:"comment_likes_enabled"`
	HasMoreComments              bool          `json:"has_more_comments"`
	MaxNumVisiblePreviewComments int           `json:"max_num_visible_preview_comments"`
	PreviewComments              []interface{} `json:"preview_comments"`
	Comments                     []interface{} `json:"comments"`
	CommentCount                 int           `json:"comment_count"`
	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         *User  `json:"user"`
		MediaID      int64  `json:"media_id"`
	} `json:"caption"`
	CaptionIsEdited bool  `json:"caption_is_edited"`
	PhotoOfYou      bool  `json:"photo_of_you"`
	NextMaxID       int64 `json:"next_max_id,omitempty"`
	Location        struct {
		Pk               int     `json:"pk"`
		Name             string  `json:"name"`
		Address          string  `json:"address"`
		City             string  `json:"city"`
		Lng              float64 `json:"lng"`
		Lat              float64 `json:"lat"`
		ExternalSource   string  `json:"external_source"`
		FacebookPlacesID int64   `json:"facebook_places_id"`
	} `json:"location,omitempty"`
	Lat           float64 `json:"lat,omitempty"`
	Lng           float64 `json:"lng,omitempty"`
	ViewCount     float64 `json:"view_count,omitempty"`
	VideoVersions []struct {
		Type   int    `json:"type"`
		Width  int    `json:"width"`
		Height int    `json:"height"`
		URL    string `json:"url"`
	} `json:"video_versions,omitempty"`
	HasAudio      bool    `json:"has_audio,omitempty"`
	VideoDuration float64 `json:"video_duration,omitempty"`
}

type LikeResponse

type LikeResponse struct {
	Status string `json:"status"`
}

type LoggedInUser

type LoggedInUser struct {
	AllowContactsSync bool   `json:"allow_contacts_sync"`
	FullName          string `json:"full_name"`
	IsPrivate         bool   `json:"is_private"`
	IsVerified        bool   `json:"is_verified"`
	ProfilePic        string `json:"profile_pic"`
	Username          string `json:"username"`
	AnonProfilePic    bool   `json:"has_anonymous_profile_picture"`
	PK                int    `json:"pk"`
}

type LoginResponse

type LoginResponse struct {
	*LoggedInUser `json:"logged_in_user"`
	Status        string `json:"status"`
}

type SearchUsernameResponse

type SearchUsernameResponse struct {
	*UserInfo `json:"user"`
	Status    string `json:"status"`
}

type UnfollowResponse

type UnfollowResponse struct {
	LoggedInUser struct {
		Pk                         int64  `json:"pk"`
		Username                   string `json:"username"`
		FullName                   string `json:"full_name"`
		IsPrivate                  bool   `json:"is_private"`
		ProfilePicURL              string `json:"profile_pic_url"`
		IsVerified                 bool   `json:"is_verified"`
		HasAnonymousProfilePicture bool   `json:"has_anonymous_profile_picture"`
		AllowContactsSync          bool   `json:"allow_contacts_sync"`
	} `json:"logged_in_user"`
	Status string `json:"status"`
}

type User

type User struct {
	PK                         int               `json:"pk"`
	Username                   string            `json:"username"`
	FullName                   string            `json:"full_name"`
	IsPrivate                  bool              `json:"is_private"`
	IsVerified                 bool              `json:"is_verified"`
	ProfilePicURL              string            `json:"profile_pic_url"`
	ProfilePicID               string            `json:"profile_pic_id,omitempty"`
	HasAnonymousProfilePicture bool              `json:"has_anonymous_profile_picture"`
	IsFavorite                 bool              `json:"is_favorite"`
	IsUnpublished              bool              `json:"is_unpublished"`
	FriendshipStatus           *FriendshipStatus `json:"friendship_status"`
}

type UserInfo

type UserInfo struct {
	IsBusiness          bool   `json:"is_business"`
	ProfilePicURL       string `json:"profile_pic_url"`
	HdProfilePicURLInfo struct {
		Width  int    `json:"width"`
		Height int    `json:"height"`
		URL    string `json:"url"`
	} `json:"hd_profile_pic_url_info"`
	UsertagsCount              int    `json:"usertags_count"`
	ExternalLynxURL            string `json:"external_lynx_url"`
	FollowingCount             int    `json:"following_count"`
	HasAnonymousProfilePicture bool   `json:"has_anonymous_profile_picture"`
	GeoMediaCount              int    `json:"geo_media_count"`
	ExternalURL                string `json:"external_url"`
	Username                   string `json:"username"`
	Biography                  string `json:"biography"`
	HasChaining                bool   `json:"has_chaining"`
	FullName                   string `json:"full_name"`
	IsPrivate                  bool   `json:"is_private"`
	PK                         int    `json:"pk"`
	FollowerCount              int    `json:"follower_count"`
	ProfilePicID               string `json:"profile_pic_id"`
	IsVerified                 bool   `json:"is_verified"`
	HdProfilePicVersions       []struct {
		Width  int    `json:"width"`
		Height int    `json:"height"`
		URL    string `json:"url"`
	} `json:"hd_profile_pic_versions"`
	MediaCount int  `json:"media_count"`
	IsFavorite bool `json:"is_favorite"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL