📚 Official unofficial Golang bindings for Telegraph API https://telegra.ph/api
Go to file
Maxim Lebedev b3dd02e0b4
🔥 Removed myself from CONTRIBUTORS.md list
2018-01-09 15:39:29 +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
CODE_OF_CONDUCT.md 📝 Created CODE_OF_CONDUCT.md 2018-01-09 15:23:19 +05:00
CONTRIBUTORS.md 🔥 Removed myself from CONTRIBUTORS.md list 2018-01-09 15:39:29 +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 🚚 Fixed repository path to renamed package 2018-01-09 15:37:40 +05:00
content.go 🎨 Format of the comments width in structures to 80 2017-12-13 16:26:01 +05:00
create_account.go 🎨 Format of the comments width in structures to 80 2017-12-13 16:26:01 +05:00
create_page.go 🎨 Format of the comments width in structures to 80 2017-12-13 16:26:01 +05:00
doc.go 📝 Added doc.go with package description 2017-12-13 14:49:00 +05:00
edit_account_info.go 🎨 Format comments and code width 2017-12-13 15:51:15 +05:00
edit_page.go 🎨 Format comments and code width 2017-12-13 15:51:15 +05:00
get_account_info.go 🎨 Format of the comments width in structures to 80 2017-12-13 16:26:01 +05:00
get_page.go ♻️ More safe using of fasthttp.Args 2017-12-13 15:50:16 +05:00
get_page_list.go ♻️ More safe using of fasthttp.Args 2017-12-13 15:50:16 +05:00
get_views.go 💥 Reorder date arguments in GetViews method 2017-12-13 15:51:15 +05:00
invalid_test.go 💥 Reorder date arguments in GetViews method 2017-12-13 15:51:15 +05:00
request.go 🏗️ Hide Response structure because it is not publicly used anywhere 2017-12-13 16:41:04 +05:00
revoke_access_token.go 🎨 Format comments and code width 2017-12-13 15:51:15 +05:00
valid_test.go 💥 Reorder date arguments in GetViews method 2017-12-13 15:51:15 +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/telegraph

Import it in your code:
import "github.com/toby3d/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/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?