2017-06-05 23:17:58 +00:00
# GoLang bindings for the Telegraph API [![discord](https://discordapp.com/api/guilds/208605007744860163/widget.png)](https://discord.gg/QJ8z5BN)
2016-12-21 19:32:28 +00:00
> This project is just to provide a wrapper around the API without any additional features.
[![License ](https://img.shields.io/npm/l/express.svg?maxAge=2592000 )](LICENSE.md)
2017-04-15 10:06:21 +00:00
[![Build Status ](https://travis-ci.org/toby3d/go-telegraph.svg )](https://travis-ci.org/toby3d/go-telegraph)
[![GoDoc ](https://godoc.org/github.com/toby3d/go-telegraph?status.svg )](https://godoc.org/github.com/toby3d/go-telegraph)
[![Go Report ](https://goreportcard.com/badge/github.com/toby3d/go-telegraph )](https://goreportcard.com/report/github.com/toby3d/go-telegraph)
2017-01-10 10:28:23 +00:00
[![Patreon ](https://img.shields.io/badge/support-patreon-E6461A.svg?maxAge=2592000 )](https://www.patreon.com/toby3d)
2016-12-21 19:32:28 +00:00
2017-04-15 10:06:21 +00:00
All [methods ](https://toby3d.github.io/go-telegraph/#available-methods ) and [types ](https://toby3d.github.io/go-telegraph/#available-types ) available and this library (possibly) is ready for use in production. Yaay!
2016-12-21 19:32:28 +00:00
## Start using telegraph
Download and install it:
2017-04-15 10:06:21 +00:00
`$ go get -u github.com/toby3d/go-telegraph`
2016-12-21 19:32:28 +00:00
Import it in your code:
2017-04-15 10:06:21 +00:00
`import "github.com/toby3d/go-telegraph"`
2016-12-21 19:32:28 +00:00
2016-12-24 17:09:28 +00:00
## Example
2016-12-25 13:43:07 +00:00
This is an example of "quick start", which shows **how to create a new account** for future pages, as well as **creating a [first simple page](http://telegra.ph/My-super-awesome-page-12-25)** with text, picture, video and signature:
2016-12-24 17:09:28 +00:00
```go
package main
import (
"log"
2017-04-18 16:37:48 +00:00
"github.com/toby3d/go-telegraph"
2016-12-24 17:09:28 +00:00
)
2016-12-25 13:43:07 +00:00
// Example content. Be sure to wrap every media in a < figure > tag, okay? Be easy, bro.
const data = `< figure > < img src = "/file/6a5b15e7eb4d7329ca7af.jpg" / > < / figure > < p > < i > Hello< / i > , my name is
< b > Page< / b > , < u > look at me< / u > !< / p > < figure > < iframe src = "https://youtu.be/fzQ6gRAEoy0" > < / iframe >
< figcaption > Yes, you can embed youtube, vimeo and twitter widgets too!< / figcaption > < / figure > `
2016-12-24 17:09:28 +00:00
func main() {
// Create new Telegraph account. Author name/link can be epmty.
// So secure. Much anonymously. Wow.
acc, err := telegraph.CreateAccount(
"toby3d", // required for assign all new pages (invisible for others)
"Maxim Lebedev",
2017-04-15 10:26:53 +00:00
"https://t.me/toby3d",
2016-12-24 17:09:28 +00:00
)
if err != nil {
2017-04-15 10:25:58 +00:00
log.Fatalln(err.Error())
2016-12-24 17:09:28 +00:00
}
// Boom!.. And your text will be understandable for Telegraph. MAGIC.
2017-04-15 10:25:58 +00:00
content, err := telegraph.ContentFormat(data)
if err != nil {
log.Fatalln(err.Error())
}
2016-12-24 17:09:28 +00:00
newPage := & telegraph.Page{
2016-12-25 13:43:07 +00:00
Title: "My super-awesome page",
2016-12-24 17:09:28 +00:00
Content: content,
// Not necessarily, but, hey, it's just an example.
AuthorName: acc.AuthorName,
AuthorURL: acc.AuthorURL,
}
if page, err := acc.CreatePage(newPage, false); err != nil {
2017-04-15 10:25:58 +00:00
log.Fatalln(err.Error())
2016-12-24 17:09:28 +00:00
}
2017-01-16 11:43:26 +00:00
log.Println("Kaboom! Page created, look what happened:", page.URL)
2016-12-24 17:09:28 +00:00
}
```
2016-12-21 19:32:28 +00:00
## Documentation
- [Contributors ](CONTRIBUTORS.md ) and Patrons!
- [License ](LICENSE.md )