Code Monkey home page Code Monkey logo

ig's Introduction

Build Status

Instagram Basic Display API in Golang

This is a Go package that fully supports the Instagram Basic Display API.

Feel free to create an issue or send me a pull request if you have any "how-to" question or bug or suggestion when using this package. I'll try my best to reply it.

Install

Install this package with go get github.com/dvarelap/ig.git

Usage

Get profile from a ig user.

package main

import (
	"fmt"
	"github.com/dvarelap/ig.git"
)

func main() {
	var (
		client       = ig.NewClient("<ACCESS_TOKEN>")
		profile, err = client.GetProfile()
	)
        
    	checkIfErr(err)

	fmt.Println("Here's my profile:", profile)
}

The type of profile is ig.Profile struct, which has the following structure

type Profile struct {
	ID          string
	Username    string
	AccountType string
	MediaCount  string
}

and represents fields on User's fields

Get user's media.

package main

import (
	"fmt"
	"github.com/dvarelap/ig.git"
)

func main() {
	var (
		client       = ig.NewClient("<ACCESS_TOKEN>")
		media, err = client.GetMedia()
	)

	checkIfErr(err)

	fmt.Println("User's media:")
	for _, entry := range media {
		fmt.Println(entry)
	}
}

Media is a slice of type ig.Entry struct, which has the following structure

type Entry struct {
	ID           string
	Username     string
	Caption      string
	MediaType    string
	MediaURL     string
	Permalink    string
	ThumbnailURL string
	Timestamp    string
}

and represents fields on Media

Exchange access token for a long lived token.

package main

import (
	"fmt"
	"github.com/dvarelap/ig.git"
)

func main() {
	var (
		client     = ig.NewClient("<ACCESS_TOKEN>")
		token, err = client.LongLivedToken("<CLIENT_SECRET>")
	)

	checkIfErr(err)

	fmt.Println("This is my token:", token)
}

The type of token is ig.LongLiveToken struct, which has the following structure

type LongLiveToken struct {
	AccessToken string
	TokenType   string
	ExpiresIn   int64 
}

it represents Long Lived Token from described here.

Licence

This package is licensed under the MIT license. See LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.