📝 Update example and help-links in README.md

This commit is contained in:
Maxim Lebedev 2017-07-01 17:45:26 +05:00
parent 2d2e1d9205
commit b2d00eb9c5
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F

View File

@ -25,32 +25,45 @@ package main
import ( import (
"log" "log"
"github.com/toby3d/go-telegraph" telegraph "github.com/toby3d/go-telegraph"
) )
// Example content. Be sure to wrap every media in a <figure> tag, okay? Be easy, bro. // Example content. Be sure to wrap every media in a <figure> tag, okay?
const data = `<figure><img src="/file/6a5b15e7eb4d7329ca7af.jpg"/></figure><p><i>Hello</i>, my name is // Be easy, bro.
<b>Page</b>, <u>look at me</u>!</p><figure><iframe src="https://youtu.be/fzQ6gRAEoy0"></iframe> const data = `
<figcaption>Yes, you can embed youtube, vimeo and twitter widgets too!</figcaption></figure>` <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>
`
func checkError(err error) {
if err != nil {
log.Fatalln(err.Error())
}
}
func main() { func main() {
// Create new Telegraph account. Author name/link can be epmty. // Create new Telegraph account. Author name/link can be epmty.
// So secure. Much anonymously. Wow. // So secure. Much anonymously. Wow.
acc, err := telegraph.CreateAccount( newAccount := &telegraph.Account{
"toby3d", // required for assign all new pages (invisible for others) ShortName: "toby3d", // required
"Maxim Lebedev", AuthorName: "Maxim Lebedev",
"https://t.me/toby3d", AuthorURL: "https://t.me/toby3d",
)
if err != nil {
log.Fatalln(err.Error())
} }
acc, err := telegraph.CreateAccount(newAccount)
checkError(err)
// Boom!.. And your text will be understandable for Telegraph. MAGIC. // Boom!.. And your text will be understandable for Telegraph. MAGIC.
content, err := telegraph.ContentFormat(data) content, err := telegraph.ContentFormat(data)
if err != nil { checkError(err)
log.Fatalln(err.Error())
}
newPage := &telegraph.Page{ newPage := &telegraph.Page{
Title: "My super-awesome page", Title: "My super-awesome page",
Content: content, Content: content,
@ -60,14 +73,14 @@ func main() {
AuthorURL: acc.AuthorURL, AuthorURL: acc.AuthorURL,
} }
if page, err := acc.CreatePage(newPage, false); err != nil { page, err := acc.CreatePage(newPage, false)
log.Fatalln(err.Error()) checkError(err)
}
log.Println("Kaboom! Page created, look what happened:", page.URL) log.Println("Kaboom! Page created, look what happened:", page.URL)
} }
``` ```
## Documentation ## Need help?
- [Contributors](CONTRIBUTORS.md) - [Open new issue](https://github.com/toby3d/go-telegraph/issues/new) - Native solution
- [License](LICENSE.md) - [Discuss in Discord](https://discord.gg/QJ8z5BN) - Most preferred option
- [Ask me in Telegram](https://t.me/toby3d) - Less preferred option (please don't spam)