composer require abraham/twitteroauth
<?php
require_once "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
define('CONSUMER_KEY', 'consumer key here');
define('CONSUMER_SECRET', 'consumer secret here');
define('ACCESS_TOKEN', 'access token here');
define('ACCESS_TOKEN_SECRET', 'access token secret here');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$connection->setApiVersion('2');
$status_payload = [
'text' => 'Hello World ' . time(),
];
$response = $connection->post('tweets', $status_payload, true);