Exemple #1
0
func main() {
	config, err := util.LoadConfig(configFile)
	util.FailOnError(err)

	if config.ClientID == "" || config.ClientSecret == "" {
		err = fmt.Errorf("This app requires a registered API client. Please set your `client_id`, and `client_secret` config in '%v'.\n", configFile)
		util.FailOnError(err)
	}

	igConf = &oauth2.Config{
		ClientID:     config.ClientID,
		ClientSecret: config.ClientSecret,
		RedirectURL:  redirectURL,
		Endpoint: oauth2.Endpoint{
			AuthURL:  instagramAuthURL,
			TokenURL: instagramTokenURL,
		},
		Scopes: []string{
			"basic",
			"public_content",
			"follower_list",
			"comments",
			"relationships",
			"likes",
		},
	}

	http.HandleFunc("/", Home)
	http.HandleFunc("/handshake", Handshake)
	fmt.Printf("Listening and serving HTTP on %s\n", serverPort)
	http.ListenAndServe(serverPort, nil)
}
Exemple #2
0
func main() {
	// Load config
	if _, err := os.Stat(configFile); os.IsNotExist(err) {
		err = fmt.Errorf("The configuration file ('%s') cannot be found.\n", configFile)
		util.FailOnError(err)
	}

	config, err := util.LoadConfig(configFile)
	util.FailOnError(err)

	if config.AccessToken == "" {
		err = fmt.Errorf("This app requires an authenticated user. Please set your `access_token` config in '%v'.\n", configFile)
		util.FailOnError(err)
	}

	// Create an Instagram client
	client = instagram.NewClient(nil)
	client.ClientID = config.ClientID
	client.ClientSecret = config.ClientSecret
	client.AccessToken = config.AccessToken

	// Commands
	commands := []cli.Command{
		{
			Name:    "Followers",
			Aliases: []string{"fl"},
			Usage:   "Returns a list of users who are following you",
			Action:  Followers,
		},
		{
			Name:    "Following",
			Aliases: []string{"fw"},
			Usage:   "Returns a list of users who you are following",
			Action:  Following,
		},
		{
			Name:    "FollowsBack",
			Aliases: []string{"fb"},
			Usage:   "Returns a list of users who are not following you back",
			Flags: []cli.Flag{
				cli.BoolFlag{Name: "me", Usage: "Returns a list of users YOU are not following back"},
			},
			Action: FollowsBack,
		},
		{
			Name:    "Unfollowed",
			Aliases: []string{"un"},
			Usage:   "Returns a list of users who unfollowed you (since you last ran the command)",
			Action:  Unfollowed,
		},
	}

	// Create CLI
	app := cli.NewApp()
	app.Name = "instafollowers"
	app.Authors = []cli.Author{cli.Author{"Ian Lai", "*****@*****.**"}}
	app.Usage = "Manage your Instagram followers"
	app.Version = "1.4.6"
	app.Commands = commands
	app.Run(os.Args)
}