Telegraph APIフレームワーク

画像


2016年12月20日に、TelegramはTelegraphの APIを開きました。 それを処理するために、 JavaScript用のシンプルで機能的なライブラリを作成しました


Telegraphについて一言


Telegraphは、Telegramチームが開発したミニマリストスタイルのメモおよびストーリーサービスです。 また、Telegramから表示するときのインスタントビューのサポート。


電信についての詳細



設置


npm install --save telegraph-node 

接続


 const telegraph = require('telegraph-node') const ph = new telegraph() 

利用可能な方法



createAccount


アカウント作成:


 ph.createAccount(short_name, options).then((resulr) => { console.log(result) }) 

editAccountInfo


アカウントの編集:


  ph.editAccountInfo(access_token, options).then((resulr) => { console.log(result) }) 

getAccountInfo


アカウント情報の取得:


 ph.getAccountInfo(access_token, options).then((resulr) => { console.log(result) }) 

revokeAccessToken


トークンの再発行:


 ph.revokeAccessToken(access_token).then((resulr) => { console.log(result) }) 

createPage


ページ作成:


 ph.createPage(access_token, title, content, options).then((resulr) => { console.log(result) }) 

editPage


ページ編集:


 ph.editPage(access_token, path, title, content, options).then((resulr) => { console.log(result) }) 

getPage


取得ページ:


 ph.getPage(path, options).then((resulr) => { console.log(result) }) 

getPageList


ページのリストを取得する:


 ph.getPageList(access_token, options).then((resulr) => { console.log(result) }) 

getViews


ページビュー数を取得する:


 ph.getViews(path, options).then((resulr) => { console.log(result) }) 

リクエスト処理


POSTリクエストを処理してAPIに送信するために、 Tiny Requestフレームワークを使用しました


申込み


Telegram Botの作成に使用します。 多くの場合、写真や場所を含む大量の情報を表示する必要があり、多くのメッセージを送信することで問題は解決しますが、TelegraphはInstant Viewによりうまく対応できると思います。


Github


電信ノード


記事をマスターしたすべての人に感謝します。 あなたのフィードバックと提案を待っています!


更新:Promiseサポート



Source: https://habr.com/ru/post/J318474/


All Articles