📚 Official unofficial Golang bindings for Telegraph API https://telegra.ph/api
Go to file
Maxim Lebedev c65a51182d
GOTTA GO FAST
2017-05-12 02:06:32 +05:00
.gitignore 🏁 Fast start 2016-12-22 00:37:14 +05:00
.travis.yml 😎 Kaboom! All done and closes #1 2016-12-24 22:09:28 +05:00
CONTRIBUTORS.md 🏁 Fast start 2016-12-22 00:37:14 +05:00
LICENSE.md 🎊 2017 2017-02-02 17:51:53 +05:00
README.md ✏️ gofmt in README.md 2017-04-18 21:37:48 +05:00
account.go GOTTA GO FAST 2017-05-12 02:06:32 +05:00
content.go 🔨 Small refactoring 2017-05-05 02:05:11 +05:00
invalid_test.go 👽 ...string instead []string 2017-05-05 02:07:51 +05:00
page.go GOTTA GO FAST 2017-05-12 02:06:32 +05:00
telegraph.go GOTTA GO FAST 2017-05-12 02:06:32 +05:00
valid_test.go 👽 ...string instead []string 2017-05-05 02:07:51 +05:00

README.md

GoLang bindings for the Telegraph API discord

This project is just to provide a wrapper around the API without any additional features.

License
Build Status
GoDoc
Go Report
Patreon

All methods and types available and this library (possibly) is ready for use in production. Yaay!

Start using telegraph

Download and install it:
$ go get -u github.com/toby3d/go-telegraph

Import it in your code:
import "github.com/toby3d/go-telegraph"

Example

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 with text, picture, video and signature:

package main

import (
    "log"

    "github.com/toby3d/go-telegraph"
)

// 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>`

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",
        "https://t.me/toby3d",
    )
    if err != nil {
        log.Fatalln(err.Error())
    }

    // Boom!.. And your text will be understandable for Telegraph. MAGIC.
    content, err := telegraph.ContentFormat(data)
    if err != nil {
        log.Fatalln(err.Error())
    }
    
    newPage := &telegraph.Page{
        Title:   "My super-awesome page",
        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 {
        log.Fatalln(err.Error())
    }
	
    log.Println("Kaboom! Page created, look what happened:", page.URL)
}

Documentation