Documentation
¶
Overview ¶
gostagram is an unofficial go client for the instagram api.
note: there's two way to get the access token, using oauth2 golang library or using curl (both ways need a local server to get the token).
Index ¶
- Variables
- func Version() string
- type BaseMediaCarousel
- type BaseMediaResource
- type Client
- func (c Client) ApproveUserById(user_id string) (*Relationship, error)
- func (c Client) BlockUserById(user_id string) (*Relationship, error)
- func (c Client) CreateSubscription() error
- func (c Client) DeleteMediaComment(media_id, comment_id string) error
- func (c Client) DeleteMediaLike(media_id string) error
- func (c Client) DeleteSubscription() error
- func (c Client) FollowUserById(user_id string) (*Relationship, error)
- func (c Client) GetCurrentUser() (*UserDetailed, error)
- func (c Client) GetCurrentUserFollowedBy() ([]*User, error)
- func (c Client) GetCurrentUserFollows() ([]*User, error)
- func (c Client) GetCurrentUserMediaLiked(max_like_id string, parameters Parameters) ([]*Media, error)
- func (c Client) GetCurrentUserRecentMedia(params Parameters) ([]*Media, error)
- func (c Client) GetCurrentUserRelationship(user_id string) (*Relationship, error)
- func (c Client) GetCurrentUserRequestedBy() ([]*User, error)
- func (c Client) GetLocationById(location_id string) (*Location, error)
- func (c Client) GetMediaById(media_id string) (*Media, error)
- func (c Client) GetMediaByShortcode(short_code string) (*Media, error)
- func (c Client) GetMediaComments(media_id string) ([]*Comment, error)
- func (c Client) GetMediaLikes(media_id string) ([]*User, error)
- func (c Client) GetRecentMediaLocation(location_id string, params Parameters) ([]*Media, error)
- func (c Client) GetRecentMediaTaggedByTagName(tagname string, params Parameters) ([]*Media, error)
- func (c Client) GetTagByName(tagname string) (*Tag, error)
- func (c Client) GetUser(id string) (*UserDetailed, error)
- func (c Client) GetUserMedia(user_id string, params Parameters) ([]*Media, error)
- func (c Client) IgnoreUserById(user_id string) (*Relationship, error)
- func (c Client) ListSubscription() error
- func (c Client) PostMediaComment(text, media_id string) error
- func (c Client) PostMediaLike(media_id string) error
- func (c Client) SearchLocations(latitude, longitude string, params Parameters) ([]*Location, error)
- func (c Client) SearchMedia(lat, long string, params Parameters) ([]*Media, error)
- func (c Client) SearchTags(query string) ([]*Tag, error)
- func (c Client) SearchUsers(query string, parameters Parameters) ([]*User, error)
- func (c *Client) SetClientId(id string)
- func (c *Client) SetClientSecret(cs string)
- func (c *Client) SetSignedRequest(sr bool)
- func (c Client) UnBlockUserById(user_id string) (*Relationship, error)
- func (c Client) UnFollowUserById(user_id string) (*Relationship, error)
- type Comment
- type Image
- type Location
- type Media
- type MediaCarousel
- type MediaCarouselImage
- type MediaCarouselVideo
- type MediaImage
- type MediaType
- type MediaVideo
- type Parameters
- type Relationship
- type Tag
- type User
- type UserDetailed
- type VideoResolution
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // errors that should be throw // if you want to post a comment // incorrectly. CommentsUrlExceed = errors.New("Comment cannot contain more than 1 URL.") CommentsHashtagExceed = errors.New("Comment cannot contain more than 4 hashtags.") CommentsMaxLengthExceed = errors.New("Comment cannot exceed 300 characters.") CommentsCapitalLettersError = errors.New("Comment cannot consist of all capital letters") MissingCommentError = errors.New("Comment cannot be empty.") )
var ( ClientSecretNotSetError = errors.New("Client secret not set for signed request.") WrongInstagramEndpointError = errors.New("Wrong instagram endpoint.") )
var (
SubscriptionError = errors.New("Subscriptions not yet supported.")
)
Functions ¶
Types ¶
type BaseMediaCarousel ¶
type BaseMediaCarousel struct {
Type string
UserInPhoto []struct {
User User
Position struct {
X int
Y int
}
} `mapstructure:"user_in_photo"`
}
Carousel resource can have both image and video resources with it, those resources base attributes are with are in BaseMediaCarousel struct.
type BaseMediaResource ¶
type BaseMediaResource struct {
Id string
Type string
Link string
Filter string
CreatedTime string `mapstructure:"created_time"`
User User
UserHasLiked bool `mapstructure:"user_has_liked"`
Attribution interface{}
Tags []string
UserInPhoto []struct {
User User
Position struct {
X int
Y int
}
} `mapstructure:"user_in_photo"`
Comments struct {
Count int
}
Caption struct {
From User
Id string
Text string
CreatedTime string
}
Likes struct {
Count int
}
Images struct {
Thumbnail Image
LowResolution Image `mapstructure:"low_resolution"`
StandardResolution Image `mapstructure:"standard_resolution"`
}
Location struct {
Id string
Name string
Latitude float64
Longitude float64
StreetAddress string `mapstructure:"street_address"`
}
}
BaseMediaResource represent all attributes that all media resources may has.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Instagram client.
Example ¶
prints current user id, username and fullname.
client := NewClient("access_token")
user, err := client.GetCurrentUser()
if err != nil {
fmt.Println(err)
} else {
fmt.Println(user.Id)
fmt.Println(user.Username)
fmt.Println(user.FullName)
}
Example (Secure) ¶
prints instagram tags with golang query
client := NewClient("access_token")
client.SetSignedRequest(true)
client.SetClientSecret("client secret")
tags, err := client.SearchTags("golang")
if err != nil {
fmt.Println(err)
} else {
for _, tag := range tags {
fmt.Println("Tag name: ", tag.Name)
}
}
func (Client) ApproveUserById ¶
func (c Client) ApproveUserById(user_id string) (*Relationship, error)
func (Client) BlockUserById ¶
func (c Client) BlockUserById(user_id string) (*Relationship, error)
func (Client) CreateSubscription ¶
func (Client) DeleteMediaComment ¶
Delete a comment from a media resource for more information about it, go to https://www.instagram.com/developer/endpoints/comments/#delete_media_comments
func (Client) DeleteMediaLike ¶
Delete a media resource, with a respective id, for more information about it, go to https://www.instagram.com/developer/endpoints/likes/#delete_likes
func (Client) DeleteSubscription ¶
func (Client) FollowUserById ¶
func (c Client) FollowUserById(user_id string) (*Relationship, error)
func (Client) GetCurrentUser ¶
func (c Client) GetCurrentUser() (*UserDetailed, error)
Get current logged user data, for more information go to https://www.instagram.com/developer/endpoints/users/#get_users_self
func (Client) GetCurrentUserFollowedBy ¶
Get a list of users, that current user is followed, for more information go to https://www.instagram.com/developer/endpoints/relationships/#get_users_followed_by
func (Client) GetCurrentUserFollows ¶
Get a list of users that current user follows, for more information go to https://www.instagram.com/developer/endpoints/relationships/#get_users_follows
func (Client) GetCurrentUserMediaLiked ¶
func (c Client) GetCurrentUserMediaLiked(max_like_id string, parameters Parameters) ([]*Media, error)
Get the recent media liked by the current user, for more information aboit it, go to https://www.instagram.com/developer/endpoints/users/#get_users_feed_liked
func (Client) GetCurrentUserRecentMedia ¶
func (c Client) GetCurrentUserRecentMedia(params Parameters) ([]*Media, error)
Get current user media resources and how many resources want to return.
func (Client) GetCurrentUserRelationship ¶
func (c Client) GetCurrentUserRelationship(user_id string) (*Relationship, error)
Check current user relationship with other user by it's id, for more information about it, go to https://www.instagram.com/developer/endpoints/relationships/#get_relationship
func (Client) GetCurrentUserRequestedBy ¶
Get a list of users who have requested this user's permission to follow, for more information go to https://www.instagram.com/developer/endpoints/relationships/#get_incoming_requests
func (Client) GetLocationById ¶
Get an especific location by a respective id, for more information about it, go to https://www.instagram.com/developer/endpoints/locations/#get_locations
func (Client) GetMediaById ¶
Get media resource by id, for more information about it, go to https://www.instagram.com/developer/endpoints/media/#get_media
func (Client) GetMediaByShortcode ¶
Get media resouce by its shortcode, for more information about it, go to https://www.instagram.com/developer/endpoints/media/#get_media_by_shortcode
func (Client) GetMediaComments ¶
Get all comments from a media resource, for more information about it, go to https://www.instagram.com/developer/endpoints/comments/#get_media_comments
func (Client) GetMediaLikes ¶
Get 'likes' from media resource with the respective id, for more information about it, go to https://www.instagram.com/developer/endpoints/likes/#get_media_likes
func (Client) GetRecentMediaLocation ¶
func (c Client) GetRecentMediaLocation(location_id string, params Parameters) ([]*Media, error)
Get media resources from a respective location id, for more information about it, go to https://www.instagram.com/developer/endpoints/locations/#get_locations_media_recent
func (Client) GetRecentMediaTaggedByTagName ¶
func (c Client) GetRecentMediaTaggedByTagName(tagname string, params Parameters) ([]*Media, error)
Get media resources that has hashtags equal to 'tagname', for more information about it, go to https://www.instagram.com/developer/endpoints/tags/#get_tags_media_recent
func (Client) GetTagByName ¶
Get tags(name and how many times was use it), by name for more information about it, go to https://www.instagram.com/developer/endpoints/tags/#get_tags
func (Client) GetUser ¶
func (c Client) GetUser(id string) (*UserDetailed, error)
Get other user data, got more information go to https://www.instagram.com/developer/endpoints/users/#get_users
func (Client) GetUserMedia ¶
func (c Client) GetUserMedia(user_id string, params Parameters) ([]*Media, error)
Get media resources from respective user_id, for more information about it, go to https://www.instagram.com/developer/endpoints/users/#get_users_media_recent
func (Client) IgnoreUserById ¶
func (c Client) IgnoreUserById(user_id string) (*Relationship, error)
func (Client) ListSubscription ¶
func (Client) PostMediaComment ¶
To post a comment in a media resource, we need to follow some instagram rules, you can find them at https://www.instagram.com/developer/endpoints/comments/#post_media_comments.
func (Client) PostMediaLike ¶
Do like a media resource, with a respective id, for more information about it, go to https://www.instagram.com/developer/endpoints/likes/#post_likes
func (Client) SearchLocations ¶
func (c Client) SearchLocations(latitude, longitude string, params Parameters) ([]*Location, error)
Search locations by its latitude, longitude, distance and facebook places, for more information about it, go to https://www.instagram.com/developer/endpoints/locations/#get_locations_search
func (Client) SearchMedia ¶
func (c Client) SearchMedia(lat, long string, params Parameters) ([]*Media, error)
Get media resouces by latitude, longitude and distance, for more information about it, go to https://www.instagram.com/developer/endpoints/media/#get_media_search
func (Client) SearchTags ¶
Search tags by a query, for more information about it, go to https://www.instagram.com/developer/endpoints/tags/#get_tags_search
func (Client) SearchUsers ¶
func (c Client) SearchUsers(query string, parameters Parameters) ([]*User, error)
get a list of users from the query, for more information go to https://www.instagram.com/developer/endpoints/users/#get_users_search
func (*Client) SetClientId ¶
func (*Client) SetClientSecret ¶
func (*Client) SetSignedRequest ¶
func (Client) UnBlockUserById ¶
func (c Client) UnBlockUserById(user_id string) (*Relationship, error)
func (Client) UnFollowUserById ¶
func (c Client) UnFollowUserById(user_id string) (*Relationship, error)
type Comment ¶
type Comment struct {
From User
Id string
Text string
CreatedTime string `mapstructure:"created_time"`
}
Media resource comment representation.
type Media ¶
type Media interface {
MediaType() MediaType
}
Media is a generic interface that represents all valid instagram media resources (Images, videos and carousel images).
type MediaCarousel ¶
type MediaCarousel struct {
BaseMediaResource `mapstructure:",squash"`
CarouselMedia []Media
}
MediaCarousel struct represents an Image resource that instagram endpoint returns.
func (MediaCarousel) MediaType ¶
func (mi MediaCarousel) MediaType() MediaType
type MediaCarouselImage ¶
type MediaCarouselImage struct {
BaseMediaCarousel `mapstructure:",squash"`
Images struct {
Thumbnail Image
LowResolution Image `mapstructure:"low_resolution"`
StandardResolution Image `mapstructure:"standard_resolution"`
}
}
func (MediaCarouselImage) MediaType ¶
func (mi MediaCarouselImage) MediaType() MediaType
type MediaCarouselVideo ¶
type MediaCarouselVideo struct {
BaseMediaCarousel `mapstructure:",squash"`
Videos struct {
LowResolution VideoResolution `mapstructure:"low_resolution"`
LowBandwidth VideoResolution `mapstructure:"low_bandwidth"`
StandardResolution VideoResolution `mapstructure:"standard_resolution"`
}
}
func (MediaCarouselVideo) MediaType ¶
func (mi MediaCarouselVideo) MediaType() MediaType
type MediaImage ¶
type MediaImage struct {
BaseMediaResource `mapstructure:",squash"`
}
MediaImage struct represents an Image resource that instagram endpoint returns.
func (MediaImage) MediaType ¶
func (mi MediaImage) MediaType() MediaType
type MediaType ¶
type MediaType uint8
Represents every media file's type, normaly used to differentiate video, image and carousel resources from a Media interface array ([]Media).
func (MediaType) IsCarousel ¶
type MediaVideo ¶
type MediaVideo struct {
BaseMediaResource `mapstructure:",squash"`
Videos struct {
LowResolution VideoResolution `mapstructure:"low_resolution"`
StandardResolution VideoResolution `mapstructure:"standard_resolution"`
}
}
MediaVideo struct represents an Image resource that instagram endpoint returns.
func (MediaVideo) MediaType ¶
func (mi MediaVideo) MediaType() MediaType
type Parameters ¶
type Relationship ¶
type Relationship struct {
OutgoingStatus string `mapstructure:"outgoing_status"`
IncomingStatus string `mapstructure:"incoming_status"`
}
Relationship struct represent relationship status with another user.
func (Relationship) BlockedByYou ¶
func (r Relationship) BlockedByYou() bool
check if current user was blocked by other user.
func (Relationship) FollowedBy ¶
func (r Relationship) FollowedBy() bool
check if current user was followed by other user
func (Relationship) Follows ¶
func (r Relationship) Follows() bool
check if current user follows other user
func (Relationship) Requested ¶
func (r Relationship) Requested() bool
check if current user send a request to follow other user.
func (Relationship) RequestedBy ¶
func (r Relationship) RequestedBy() bool
check if current user was requested by other user to accept the follow.
type User ¶
type User struct {
Id string
Type string
Username string
LastName string `mapstructure:"last_name"`
FirstName string `mapstructure:"first_name"`
ProfilePicture string `mapstructure:"profile_picture"`
}
User struct represents main user information, most of the time, returned by comments or media metadata.
type UserDetailed ¶
type UserDetailed struct {
Id string
Bio string
Website string
Username string
FullName string `mapstructure:"full_name"`
ProfilePicture string `mapstructure:"profile_picture"`
Counts struct {
Media int
Follows int
FollowedBy int `mapstructure:"followed_by"`
}
}
UserDetailed struct represents user profile information.