instagram

package
v0.0.0-...-afbeb1f Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

AUTHOR:HARSH AGRAWAL19BCE10101

AUTHOR:HARSH AGRAWAL 19BCE10101

Index

Constants

View Source
const (
	// LibraryVersion represents this library version
	LibraryVersion = "0.5"

	// BaseURL represents Instagram API base URL
	BaseURL = "https://api.instagram.com/v1/"

	// UserAgent represents this client User-Agent
	UserAgent = "github.com/harsh3125/Instagram-backend-api" + LibraryVersion
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for error, and returns it if present. A response is considered an error if it has non StatusOK code.

func TestCommentsService_Add

func TestCommentsService_Add(t *testing.T)

func TestCommentsService_Delete

func TestCommentsService_Delete(t *testing.T)

func TestCommentsService_MediaComments

func TestCommentsService_MediaComments(t *testing.T)

func TestGeographiesService_RecentMedia

func TestGeographiesService_RecentMedia(t *testing.T)

func TestLocationsService_Get

func TestLocationsService_Get(t *testing.T)

func TestLocationsService_RecentMedia

func TestLocationsService_RecentMedia(t *testing.T)
func TestLocationsService_Search(t *testing.T)

func TestMediaService_Get

func TestMediaService_Get(t *testing.T)
func TestMediaService_Popular(t *testing.T)
func TestMediaService_Search(t *testing.T)

func TestNewClient

func TestNewClient(t *testing.T)

func TestNewRequest

func TestNewRequest(t *testing.T)

func TestRelationshipsService_FollowedBy_self

func TestRelationshipsService_FollowedBy_self(t *testing.T)

func TestRelationshipsService_FollowedBy_userId

func TestRelationshipsService_FollowedBy_userId(t *testing.T)

func TestRelationshipsService_Follows_self

func TestRelationshipsService_Follows_self(t *testing.T)

func TestRelationshipsService_Follows_userId

func TestRelationshipsService_Follows_userId(t *testing.T)

func TestRelationshipsService_Relationship

func TestRelationshipsService_Relationship(t *testing.T)

func TestRelationshipsService_RequestedBy

func TestRelationshipsService_RequestedBy(t *testing.T)

func TestRelationshipsService_actions

func TestRelationshipsService_actions(t *testing.T)

func TestUsersService_Get_self

func TestUsersService_Get_self(t *testing.T)

func TestUsersService_Get_userId

func TestUsersService_Get_userId(t *testing.T)

func TestUsersService_LikedMedia

func TestUsersService_LikedMedia(t *testing.T)

func TestUsersService_MediaFeed

func TestUsersService_MediaFeed(t *testing.T)

func TestUsersService_RecentMedia

func TestUsersService_RecentMedia(t *testing.T)
func TestUsersService_Search(t *testing.T)

Types

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// UserAgent agent used when communicating with Instagram API.
	UserAgent string

	// Application client_id
	ClientID string

	// Application client_secret
	ClientSecret string

	// Authenticated user's access_token
	AccessToken string

	// Services used for talking to different parts of the API.
	Users         *UsersService
	Relationships *RelationshipsService
	Media         *MediaService
	Comments      *CommentsService
	Likes         *LikesService
	Tags          *TagsService
	Locations     *LocationsService
	Geographies   *GeographiesService

	// Temporary Response
	Response *Response
	// contains filtered or unexported fields
}

A Client manages communication with the Instagram API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Instagram API client. if a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body string) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified

type Comment

type Comment struct {
	CreatedTime int64  `json:"created_time,string,omitempty"`
	Text        string `json:"text,omitempty"`
	From        *User  `json:"from,omitempty"`
	ID          string `json:"id,omitempty"`
}

type CommentsService

type CommentsService struct {
	// contains filtered or unexported fields
}

func (*CommentsService) Add

func (s *CommentsService) Add(mediaId string, text []string) error

func (*CommentsService) Delete

func (s *CommentsService) Delete(mediaId, commentId string) error

func (*CommentsService) MediaComments

func (s *CommentsService) MediaComments(mediaId string) ([]Comment, error)

type ErrorResponse

type ErrorResponse Response

ErrorResponse represents a Response which contains an error

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type GeographiesService

type GeographiesService struct {
	// contains filtered or unexported fields
}

func (*GeographiesService) RecentMedia

func (s *GeographiesService) RecentMedia(geoId string, opt *Parameters) ([]Media, *ResponsePagination, error)

type Location

type Location struct {
	ID        string  `json:"id,omitempty"`
	Name      string  `json:"name,omitempty"`
	Latitude  float64 `json:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
}

Location represents information about a location.

type LocationsService

type LocationsService struct {
	// contains filtered or unexported fields
}

func (*LocationsService) Get

func (s *LocationsService) Get(locationId string) (*Location, error)

func (*LocationsService) RecentMedia

func (s *LocationsService) RecentMedia(locationId string, opt *Parameters) ([]Media, *ResponsePagination, error)

func (*LocationsService) Search

func (s *LocationsService) Search(lat, lng float64, opt *Parameters) ([]Location, error)

type Media

type Media struct {
	Type         string         `json:"type,omitempty"`
	UsersInPhoto []*UserInPhoto `json:"users_in_photo,omitempty"`
	Filter       string         `json:"filter,omitempty"`
	Tags         []string       `json:"tags,omitempty"`
	Comments     *MediaComments `json:"comments,omitempty"`
	Caption      *MediaCaption  `json:"caption,omitempty"`
	Likes        *MediaLikes    `json:"likes,omitempty"`
	Link         string         `json:"link,omitempty"`
	User         *User          `json:"user,omitempty"`
	UserHasLiked bool           `json:"user_has_liked,omitempty"`
	CreatedTime  int64          `json:"created_time,string,omitempty"`
	Images       *MediaImages   `json:"images,omitempty"`
	Videos       *MediaVideos   `json:"videos,omitempty"`
	ID           string         `json:"id,omitempty"`
	Location     *MediaLocation `json:"location,omitempty"`
}

type MediaCaption

type MediaCaption struct {
	CreatedTime int64  `json:"created_time,string,omitempty"`
	Text        string `json:"text,omitempty"`
	From        *User  `json:"from,omitempty"`
	ID          string `json:"id,omitempty"`
}

type MediaComments

type MediaComments struct {
	Count int        `json:"count,omitempty"`
	Data  []*Comment `json:"data,omitempty"`
}

type MediaImage

type MediaImage struct {
	URL    string `json:"url,omitempty"`
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
}

type MediaImages

type MediaImages struct {
	LowResolution      *MediaImage `json:"low_resolution,omitempty"`
	Thumbnail          *MediaImage `json:"thumbnail,omitempty"`
	StandardResolution *MediaImage `json:"standard_resolution,omitempty"`
}

type MediaLikes

type MediaLikes struct {
	Count int `json:"count,omitempty"`
	Data  []*User
}

type MediaLocation

type MediaLocation struct {
	ID        int     `json:"id,omitempty"`
	Name      string  `json:"name,omitempty"`
	Latitude  float64 `json:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
}

type MediaService

type MediaService struct {
	// contains filtered or unexported fields
}

func (*MediaService) Get

func (s *MediaService) Get(mediaId string) (*Media, error)

func (*MediaService) Popular

func (s *MediaService) Popular() ([]Media, *ResponsePagination, error)

func (*MediaService) Search

func (s *MediaService) Search(opt *Parameters) ([]Media, *ResponsePagination, error)

type MediaVideo

type MediaVideo struct {
	URL    string `json:"url,omitempty"`
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
}

type MediaVideos

type MediaVideos struct {
	LowResolution      *MediaVideo `json:"low_resolution,omitempty"`
	StandardResolution *MediaVideo `json:"standard_resolution,omitempty"`
}

type Parameters

type Parameters struct {
	Count        uint64
	MinID        string
	MaxID        string
	MinTimestamp int64
	MaxTimestamp int64
	Lat          float64
	Lng          float64
	Distance     float64
}

Parameters specifies the optional parameters to various service's methods.

type Ratelimit

type Ratelimit struct {
	// Total number of possible calls per hour
	Limit int

	// How many calls are left for this particular token or client ID
	Remaining int
}

Ratelimit specifies API calls limit found in HTTP headers.

type Relationship

type Relationship struct {
	OutgoingStatus string `json:"outgoing_status,omitempty"`

	IncomingStatus string `json:"incoming_status,omitempty"`
}

type RelationshipsService

type RelationshipsService struct {
	// contains filtered or unexported fields
}

func (*RelationshipsService) Approve

func (s *RelationshipsService) Approve(userId string) (*Relationship, error)

func (*RelationshipsService) Block

func (s *RelationshipsService) Block(userId string) (*Relationship, error)

func (*RelationshipsService) Deny

func (s *RelationshipsService) Deny(userId string) (*Relationship, error)

func (*RelationshipsService) Follow

func (s *RelationshipsService) Follow(userId string) (*Relationship, error)

func (*RelationshipsService) FollowedBy

func (s *RelationshipsService) FollowedBy(userId string) ([]User, *ResponsePagination, error)

func (*RelationshipsService) Follows

func (s *RelationshipsService) Follows(userId string) ([]User, *ResponsePagination, error)

func (*RelationshipsService) Relationship

func (s *RelationshipsService) Relationship(userId string) (*Relationship, error)

func (*RelationshipsService) RequestedBy

func (s *RelationshipsService) RequestedBy() ([]User, *ResponsePagination, error)

func (*RelationshipsService) Unblock

func (s *RelationshipsService) Unblock(userId string) (*Relationship, error)

func (*RelationshipsService) Unfollow

func (s *RelationshipsService) Unfollow(userId string) (*Relationship, error)

type Response

type Response struct {
	Response   *http.Response      // HTTP response
	Meta       *ResponseMeta       `json:"meta,omitempty"`
	Data       interface{}         `json:"data,omitempty"`
	Pagination *ResponsePagination `json:"pagination,omitempty"`
}

Response specifies Instagram's response structure.

Instagram's envelope structure spec: http://instagram.com/developer/endpoints/#structure

func (*Response) GetData

func (r *Response) GetData() interface{}

GetData gets the meat of the response.

func (*Response) GetError

func (r *Response) GetError() error

GetError gets error from meta's response.

func (*Response) GetMeta

func (r *Response) GetMeta() *ResponseMeta

GetMeta gets extra information about the response. If all goes well, only Code key with value 200 is returned. If something goes wrong, ErrorType and ErrorMessage keys are present.

func (*Response) GetPagination

func (r *Response) GetPagination() *ResponsePagination

GetPagination gets pagination information.

func (*Response) GetRatelimit

func (r *Response) GetRatelimit() (Ratelimit, error)

Parsed rate limit information from response headers.

func (*Response) NextMaxID

func (r *Response) NextMaxID() string

NextMaxID gets MaxID parameter that can be passed for next request.

func (*Response) NextURL

func (r *Response) NextURL() string

NextURL gets next url which represents URL for next set of data.

type ResponseMeta

type ResponseMeta struct {
	ErrorType    string `json:"error_type,omitempty"`
	Code         int    `json:"code,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`
}

ResponseMeta represents information about the response. If all goes well, only a Code key with value 200 will present. However, sometimes things go wrong, and in that case ErrorType and ErrorMessage are present.

type ResponsePagination

type ResponsePagination struct {
	NextURL   string `json:"next_url,omitempty"`
	NextMaxID string `json:"next_max_id,omitempty"`
}

ResponsePagination represents information to get access to more data in any request for sequential data.

type User

type User struct {
	ID             string     `json:"id,omitempty"`
	Username       string     `json:"username,omitempty"`
	FullName       string     `json:"full_name,omitempty"`
	ProfilePicture string     `json:"profile_picture,omitempty"`
	Bio            string     `json:"bio,omitempty"`
	Website        string     `json:"website,omitempty"`
	Counts         *UserCount `json:"counts,omitempty"`
}

type UserCount

type UserCount struct {
	Media      int `json:"media,omitempty"`
	Follows    int `json:"follows,omitempty"`
	FollowedBy int `json:"followed_by,omitempty"`
}

type UserInPhoto

type UserInPhoto struct {
	User     *User                `json:"user,omitempty"`
	Position *UserInPhotoPosition `json:"position,omitempty"`
}

type UserInPhotoPosition

type UserInPhotoPosition struct {
	// contains filtered or unexported fields
}

type UsersService

type UsersService struct {
	// contains filtered or unexported fields
}

func (*UsersService) Get

func (s *UsersService) Get(userId string) (*User, error)

func (*UsersService) LikedMedia

func (s *UsersService) LikedMedia(opt *Parameters) ([]Media, *ResponsePagination, error)

func (*UsersService) MediaFeed

func (s *UsersService) MediaFeed(opt *Parameters) ([]Media, *ResponsePagination, error)

func (*UsersService) RecentMedia

func (s *UsersService) RecentMedia(userId string, opt *Parameters) ([]Media, *ResponsePagination, error)

func (*UsersService) Search

func (s *UsersService) Search(q string, opt *Parameters) ([]User, *ResponsePagination, error)

Jump to

Keyboard shortcuts

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