项目作者: hackerth

项目描述 :
Simple Bitly, Google URL Shortener API client for Go.
高级语言: Go
项目地址: git://github.com/hackerth/go-shortener.git
创建时间: 2018-03-10T11:23:56Z
项目社区:https://github.com/hackerth/go-shortener

开源协议:

下载


go-shortener

Simple Bitly, Google URL Shortener API client for Go.

Usage

  1. $ go get github.com/dongri/go-shortener
  1. package main
  2. import (
  3. "fmt"
  4. shortener "github.com/dongri/go-shortener"
  5. )
  6. func main() {
  7. // bitly
  8. b := shortener.NewBitly("{ACCESS_TOKEN}")
  9. shortURL, err := b.Short("http://hoge.com")
  10. fmt.Println(shortURL) // http://bit.ly/2DahJMA
  11. longURL, err := b.Long(shortURL)
  12. fmt.Println(longURL) // http://hoge.com/
  13. // goo.gl
  14. g := shortener.NewGoogl("{GOOGLE_API_KEY}")
  15. shortURL, err = g.Short("http://hoge.com")
  16. fmt.Println(shortURL) // https://goo.gl/hQMZ6
  17. longURL, err = g.Long(shortURL)
  18. fmt.Println(longURL) // http://hoge.com/
  19. // clacky.org
  20. c := shortener.NewClacky("{ACCESS_TOKEN}")
  21. shortURL, err = c.Short("http://hoge.com")
  22. fmt.Println(shortURL) // https://clacky.org/HuOe
  23. longURL, err = g.Long(shortURL)
  24. fmt.Println(longURL) // http://hoge.com/
  25. }