PHP code example of trukes / threads-api-php-client

1. Go to this page and download the library: Download trukes/threads-api-php-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

trukes / threads-api-php-client example snippets




use Trukes\ThreadsApiPhpClient\Threads;

$client = Threads::client('<your_token_here>');


$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'];

$create = $client->publish()->publish(
    'threads_user_id',
    '129984213'
)->data();

echo 'Post created successfully. Media container ID: ' . $response['id'];