Skip to content

Trukes/threads-api-php-client

Repository files navigation

Threads Meta API PHP Integration [WIP]

License PHP Version

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

  1. Fork the repository.
  2. Create a new branch for your feature (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. 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 [email protected].

⭐️ 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).