belesspathetic / fb_poster

An unofficial Rust API client for Facebook post uploads.
3 stars 1 forks source link

An unofficial Rust API client for Facebook post uploads.

🪛 Requirements

🪧 Usage

Post

use fb_poster::*;
use anyhow::{Ok, Result};

const ACCESS_TOKEN: &str = "YOUR_ACCESS_TOKEN";
const PAGE_ID: &str = "YOUR_PAGE_ID";

#[tokio::main]
async fn main() -> Result<()> {
    // Bring your secrets into a scope
    let secrets = Secrets::new(ACCESS_TOKEN, PAGE_ID);

    let message = "Your message".to_string();
    let link = "https://your_link".to_string();

    // Build a body for a request
    let body = Post::new(secrets)
    .with_message(message)
    .with_link(link);

    // Sending and get repsonse
    body.send().await?;

    Ok(())
}

Photo

use fb_poster::*;
use anyhow::{Ok, Result};

const ACCESS_TOKEN: &str = "YOUR_ACCESS_TOKEN";
const PAGE_ID: &str = "YOUR_PAGE_ID";

#[tokio::main]
async fn main() -> Result<()> {
    // Bring your secrets into a scope
    let secrets = Secrets::new(ACCESS_TOKEN, PAGE_ID);

    let path = "/path/to/photo.png".to_string();

    // Build a body for a request
    let body = Photo::new(secrets, path);

    // Sending and get repsonse
    body.send(&secrets).await?;

    Ok(())
}

Video

use fb_poster::*;
use anyhow::{Ok, Result};

const ACCESS_TOKEN: &str = "YOUR_ACCESS_TOKEN";
const PAGE_ID: &str = "YOUR_PAGE_ID";

#[tokio::main]
async fn main() -> Result<()> {
    // Bring your secrets into a scope
    let secrets = Secrets::new(ACCESS_TOKEN, PAGE_ID);

    let path = "/path/to/video".to_string(); // or url for .hosted_video()
    let title = "Title".to_string();
    let description = "Description".to_string();
    let thumb = "path/to/thumb".to_string();

    // Build a body for a request
    let body = Video::new(secrets)
    .local_video(path)
    .with_title(title)
    .with_description(description)
    .with_thumbnail(thumb)

    // Sending and get repsonse
    body.send().await?;

    Ok(())
}

Reels

use fb_poster::*;
use anyhow::{Ok, Result};

const ACCESS_TOKEN: &str = "YOUR_ACCESS_TOKEN";
const PAGE_ID: &str = "YOUR_PAGE_ID";

#[tokio::main]
async fn main() -> Result<()> {
    // Bring your secrets into a scope
    let secrets = Secrets::new(ACCESS_TOKEN, PAGE_ID);

    let path = "/path/to/video".to_string(); // or url for .hosted_video()
    let title = "Title".to_string();
    let description = "Description".to_string();
    let thumb = "path/to/thumb".to_string();

    // Build a body for a request
    let body = Reels::new(secrets)
    .local_video(path)
    .with_description(description)

    // Sending and get repsonse
    body.send().await?;

    Ok(())
}

✅ Features

Non-Resumable Upload (Video limitation is 1GB 20min)