Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Community Rust SDK for integrating with Meta Threads API

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

Thesephi/rusty_meta_threads

Crates.io VersionDocumentationMIT/Apache-2 licensed

A community Rust SDK that helps interact withMeta Threads API

Usage example

# configurations# assuming these env values e.g. in `.env` fileTHREADS_APP_ID=xxxxxxxxxxxxxxxTHREADS_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTHREADS_APP_AUTH_SCOPE=threads_basicTHREADS_AUTH_CODE_REDIRECT_URI=<REDIRECT_URL>
use rusty_meta_threads::{auth, profiles};//------------------------------------------------------------// CLIENT-SIDElet login_url = auth::get_threads_login_url();// now we can redirect the end-user to `login_url`,// once the end-user logs in successfully, Threads will send// a request to `<REDIRECT_URL>?code=<CODE>`, which we'll handle// on the server-side//------------------------------------------------------------// SERVER-SIDE// inside the HTTP endpoint handler logic for// e.g. my-app.domain/authlet code =    auth::get_code_from_redirect_uri("<REDIRECT_URL_WITH_CODE>");// `code` can now be exchanged for a short-lived bearer tokenlet short_lived_token =    auth::get_short_lived_bearer_token(&code).await.unwrap().access_token;// `short_lived_token` can be exchanged for// a long-lived bearer tokenlet long_lived_token =    auth::get_long_lived_bearer_token(&short_lived_token).await.unwrap().access_token;// either `short_lived_token` or `long_lived_token` can be used// to make API calls against Threads, for example:let profile_info =    profiles::get_profile_info(&long_lived_token).await.unwrap();// long-lived token can be refreshed// as long as it doesn't expire yetlet refreshed_token =    auth::refresh_long_lived_bearer_token(&long_lived_token).await.unwrap().access_token;

Contributor notice

Please seeGOVERNANCE

Running tests

export ACCESS_TOKEN=replace_with_valid_threads_api_access_tokencargotest# or if more details are neededRUST_LOG=debug cargotest

Be aware: some tests may fail ifACCESS_TOKEN is expired, ormalformed. You may get a new token as per officialThreads documentation, andthen using theirPostman playground.

About

Community Rust SDK for integrating with Meta Threads API

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp