trukes / threads-api-php-client
A PHP client library for accessing Threads from Meta
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.9
- php-http/client-common: ^2.7
- php-http/discovery: ^1.19
Requires (Dev)
- ext-http: *
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2025-02-05 00:46:36 UTC
README
A PHP library for seamless integration with the Threads API by Meta. This package provides a simple and intuitive interface for interacting with the API, making it easy to integrate with PHP applications.
Features
- Publishing: Upload and publish Threads media objects and check their status.
- Media Retrieval: Retrieve Threads media objects.
- Reply Management: Retrieve replies and conversations and hide/unhide replies.
- User: Retrieve a Threads user's posts, publishing limit, and profile.
- Insights: Retrieve insights for Threads media objects and users.
Coming soon
- Authentication: Issue - Support for OAuth2 authentication.
Requirements
- PHP 8.1 or higher
Installation
Installation is done via Composer. Simply run the following command:
composer require trukes/threads-api-php-client
Basic Usage
Client
Before using the API, you need to create a client:
require 'vendor/autoload.php'; use Trukes\ThreadsApiPhpClient\Threads; $client = Threads::client('<your_token_here>');
Create a Post
$create = $client->publish()->create( 'threads_user_id', 'media_type', 'text', 'image_url', 'video_url', 'is_carousel_item', 'children', 'reply_to_id', 'reply_control', 'allowlisted_country_codes', 'all_text', )->data(); echo 'Post created successfully. Media container ID: ' . $response['id'];
Publish a Post
$create = $client->publish()->publish( 'threads_user_id', '129984213' )->data(); echo 'Post created successfully. Media container ID: ' . $response['id'];
Threads Documentation
Complete META Threads documentation can be found here.
Package Documentation
Complete documentation can be found here.
Contributing
Contributions are welcome! If you have suggestions, fixes, or improvements, feel free to open an issue or a pull request.
How to Contribute
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contact
If you have any questions or suggestions, feel free to contact us at pedro.m.a.carmo@gmail.com.
⭐️ Show Your Support
If this project helped you or you find it useful, please give it a star ⭐️ on GitHub. It helps others discover the project and motivates us to continue developing and improving it.
Made with ❤️ by Trukes (https://github.com/Trukes).