1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Go言語 コマンドラインからツイート

1
Posted at

ソース↓

tweet.go
package main

import (
	"github.com/ChimeraCoder/anaconda"
	"os"
	"log"
)


const (
	ck  = "コンシューマーキー"
	cs  = "コンシューマーシークレット"
	at  = "アクセストークン"
	ats = "アクセストークンシークレット"
)

func tweet(text string) string{
	anaconda.SetConsumerKey(ck)
	anaconda.SetConsumerSecret(cs)
	cl := anaconda.NewTwitterApi(at,ats)
	_,err := cl.PostTweet(text,nil)
	if err != nil{
		log.Fatal(err)
	}
	return "success"
}

func main(){
	msg := os.Args[1]
	tw := tweet(msg)
	log.Println(tw)
}

システム→システム情報→システムの詳細設定から環境変数にtweet.goがあるディレクトリを追加します

terminal
go build tweet.go
tweet 投稿したい文字
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?