📚 Official unofficial Golang bindings for Telegraph API https://telegra.ph/api
Go to file
Maxim Lebedev 2aa4b849d5
Added io.Reader type support of input data for ContentFormat method
2017-12-13 15:05:27 +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 📝 Moved patrons section in CONTRIBUTORS.md to PATRONS.md 2017-08-06 23:03:49 +05:00
LICENSE.md 🎊 2017 2017-02-02 17:51:53 +05:00
PATRONS.md 👥 Updated PATRONS.md list 2017-12-08 04:31:55 +05:00
README.md 🔥 RIP CodeSponsor :( 2017-12-08 04:29:50 +05:00
content.go Added io.Reader type support of input data for ContentFormat method 2017-12-13 15:05:27 +05:00
create_account.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
create_page.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
doc.go 📝 Added doc.go with package description 2017-12-13 14:49:00 +05:00
edit_account_info.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
edit_page.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
get_account_info.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
get_page.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
get_page_list.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
get_views.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
invalid_test.go Tests refactoring 2017-10-03 18:39:23 +05:00
request.go 🔨 Refactor of request method for safe use 2017-12-13 14:59:33 +05:00
revoke_access_token.go Removed Printf usage for accelerate 2017-12-13 15:04:05 +05:00
valid_test.go Tests refactoring 2017-10-03 18:39:23 +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
Awesome

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"

    telegraph "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 checkError(err error) {
    if err != nil {
        log.Fatalln(err.Error())
    }
}

func main() {
    // Create new Telegraph account. Author name/link can be epmty.
    // So secure. Much anonymously. Wow.
    newAccount := &telegraph.Account{
        ShortName:  "toby3d", // required
        AuthorName: "Maxim Lebedev",
        AuthorURL:  "https://t.me/toby3d",
    }
    acc, err := telegraph.CreateAccount(newAccount)
    checkError(err)

    // Boom!.. And your text will be understandable for Telegraph. MAGIC.
    content, err := telegraph.ContentFormat(data)
    checkError(err)

    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,
    }

    page, err := acc.CreatePage(newPage, false)
    checkError(err)

    log.Println("Kaboom! Page created, look what happened:", page.URL)
}

Need help?