Skip to content
Ali Error edited this page Jun 9, 2019 · 14 revisions

Installation

To install gista simply run:

go get -u github.com/aliforever/gista

Getting started

Constructor

You can pass storageConfig of type *map[string]string to have gista work with a different storage rather than the default file storage (currently gista supports file storage only, so pass nil)

i, err := gista.New(nil)
if err != nil {
    fmt.Print(err)
    return
}

Login

After initializing a Gista instance, you need to login with an Instagram account, passing true as last argument (force login) will force Gista to ignore any saved sessions for the account.

username, password := "gista", "youkiddinme"
err := gista.Login(username, password, false)
if err != nil {
    fmt.Print(err)
    return
}

Error Types

Gista has its own error types that makes it easier to work with errors, most errors in gista share "Type" and "Message" and "HTTPResponse". While some of them has even more fields and functions for further details. ex:

  • CheckpointRequired has an extra function GetCheckpointUrl() that gives you the url to verify the login.
  • ChallengeRequired has GetChallenge() containing the details about the challenge.
  • TwoFactorRequired with GetTwoFactorInfo() to get the TwoFactorIdentifier needed to complete a 2-factor login.

To use error types you need to cast errors to gista errors:

err = i.Login("gista", "youmustbekiddinme", false)
if err != nil {
	switch err.(type) {
	case errs.TwoFactorRequired:
		twoFactorErr := err.(errs.TwoFactorRequired)
		fmt.Println(twoFactorErr.GetTwoFactorInfo())
	default:
		fmt.Printf("%+v", err)
	}
	return
}