Search code examples
gotwitter

How can I upload media using go-twitter bot?


I'm new to go, and have made this simple bot using go-twitter package.

package main

import (
    "fmt"
    "github.com/dghubble/go-twitter/twitter"
    "github.com/dghubble/oauth1"
)

func main() {
    consumerKey := "SECRET"
    consumerSecret := "SECRET"
    accessToken := "SECRET"
    accessSecret := "SECRET"

    config := oauth1.NewConfig(consumerKey, consumerSecret)
    token := oauth1.NewToken(accessToken, accessSecret)

    // OAuth1 http.Client will automatically authorize Requests
    httpClient := config.Client(oauth1.NoContext, token)

    // Twitter client
    client := twitter.NewClient(httpClient)

    tweet, resp, err := client.Statuses.Update("Hi baby, I'm just a bot!", nil)
    if err != nil {
        fmt.Println(err)
    }

    fmt.Printf("TWEETED: %+v , %v\n", tweet.Text, resp)
}

I'm wondering how can I upload media using this bot?

I see there is a MediaIds in the source code, but have not clue how to use that and there is no explanation in the docs.


Solution

  • There is no such functionality.