https://github.com/weakish/telegraphet
command line tool to post content on telegra.ph
https://github.com/weakish/telegraphet
Last synced: 4 days ago
JSON representation
command line tool to post content on telegra.ph
- Host: GitHub
- URL: https://github.com/weakish/telegraphet
- Owner: weakish
- License: other
- Created: 2020-04-12T05:35:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-12T05:50:32.000Z (about 6 years ago)
- Last Synced: 2025-03-02T05:28:22.823Z (over 1 year ago)
- Language: Python
- Size: 2.93 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is the available [telegraph API][api]:
- createAccount
- createPage
- editAccountInfo
- editPage
- getAccountInfo
- getPage
- getPageList
- getViews
- revokeAccessToken
[api]: https://telegra.ph/api
First, I do not care about page views, so I remove the `getViews` API.
Second, remove the account concept:
- createPage
- editPage
- getPage
Hmm, `deletePage` is missing.
And `editPage` requires an account or a special token.
Thus I make page immutable,
and remove `editPage`.
Thus only two API interfaces are left:
- createPage
- getPage
Since I only care about page content, then `getPage` is unnecessary (just go the url in browser).
Therefore I wrote this simple script to post content to telegraph.
```shell script
echo '
Hello world!
' | telegraphet hello
```
I still need to create an account beforehand though.
telegraph requires an account to create a new page.
```shell script
telegraph --init PICKUP_A_USERNAME
```
If you already have a telegraph, you can setup the access token via environment variable or configuration file.
```shell script
# config file
mkdir -p ~/.config/telegraphet
echo '{ "token": "YOUR_TOKEN" }' > ~/.config/telegraphet/config.json
# environment variable
echo '
hi
' | TELEGRAPH_TOKEN=YOUR_TOKEN telegraphet hi
```