The instagram_uploader
package is a Go module designed for uploading images and carousels to Instagram via the Graph API. It provides a simple and efficient way to publish media on Instagram programmatically. This document outlines how to use the instagram_uploader
package after its recent refactor.
- Upload single images with captions.
- Upload multiple images as a carousel post with captions.
Ensure you have Go installed on your system. Install the package with the following command:
go get -u github.com/vahaponur/instagram_uploader
Initialize the IGUploader struct with your Instagram User ID and Access Token:
uploader := instagram_uploader.New("your_instagram_user_id", "your_access_token")
To upload a single image with a caption:
mediaID, err := uploader.UploadImagePost([]string{"https://example.com/path/to/image.jpg"}, "Your caption here")
if err != nil {
log.Println(err)
}
fmt.Println("Uploaded media ID:", mediaID)
For uploading multiple images as a carousel post with a caption:
mediaID, err := uploader.UploadImagePost([]string{
"https://example.com/path/to/image1.jpg",
"https://example.com/path/to/image2.jpg",
// Add more images as needed
}, "Your caption here")
if err != nil {
log.Fatal(err)
}
fmt.Println("Uploaded carousel media ID:", mediaID)
I am open to pull requests for new functionalities or bug fixes. If you have ideas for improvements or have found a bug, feel free to submit a pull request or open an issue in the repository. Your contributions are greatly appreciated!