示例#1
0
文件: bot.go 项目: harperreed/horace
func shorten_url(long_url string, channel chan<- string, username string, api_key string) {
	bitly.SetUser(username)
	bitly.SetKey(api_key)
	max_url_length := 20
	url := long_url
	if len(url) > max_url_length {
		short_url, error := bitly.Shorten(url)
		if error == nil {
			url = short_url
		}
	}
	channel <- url
}
示例#2
0
func main() {
	bitly.SetUser("username")
	bitly.SetKey("xxxxx")
	long_url := "https://github.com/harperreed/gobitly"
	short_url, error := bitly.Shorten(long_url)
	fmt.Printf("Your long url is: %q\n", long_url)

	if error == nil {
		fmt.Printf("Your short url is: %q\n", short_url)

	}

}