telegraph-api-rs
Rust implementation of Telegraph API
Quick start
Add dependency to the Cargo.toml
[]
= "0.2.0"
Create account
use ;
let telegraph = new;
let account = telegraph.create_account
.short_name
.author_name
.send
.unwrap;
Edit account
let edited_account = telegraph.edit_account_info
.access_token
.author_name
.send
.unwrap;
Get account info
let account_info = telegraph.get_account_info
.access_token
.fields
.send
.unwrap;
Revoke access token
let account = telegraph.revoke_access_token
.access_token
.send
.unwrap;
Create page
let content = r#"
[
{
"tag": "h3",
"children": ["Hello world"]
},
{
"tag": "h4",
"children": ["Title"]
},
{
"tag": "p",
"children": [
{
"tag": "ul",
"children": ["Some text"]
}
]
}
]
"#;
let cont = build_content.unwrap;
let page = telegraph.create_page
.access_token
.title
.content
.return_content
.send
.unwrap;
Edit page
let new_content = r#"
[
{
"tag": "h3",
"children": ["Hello world"]
},
{
"tag": "h4",
"children": ["Title"]
},
{
"tag": "p",
"children": [
{
"tag": "ul",
"children": ["Some text"]
},
{
"tag": "ul",
"children": ["Some text 2"]
}
]
}
]
"#;
let new_cont = build_content.unwrap;
let edited_page = telegraph.edit_page
.access_token
.title
.path
.content
.return_content
.send
.unwrap;
Get page
let get_page = telegraph.get_page
.path
.send
.unwrap;
Get page list
let page_list = telegraph.get_page_list
.access_token
.limit
.send
.unwrap;
Get views
let count = telegraph.get_views
.path
.year
.month
.day
.hour
.send
.unwrap;
Upload media files
use Telegraph;
let telegraph = new;
let files = vec!;
let media = telegraph.upload;
You can upload media with custom client
use Telegraph;
use Client;
let client = new;
let files = vec!;
let media = upload_with;
More examples in the documentation