PHP code example of joomla / twitter

1. Go to this page and download the library: Download joomla/twitter 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/ */

    

joomla / twitter example snippets


use Joomla\Twitter\Twitter;

$twitter = new Twitter;

use Joomla\Http\Http;
use Joomla\Twitter\Twitter;
use Joomla\Twitter\OAuth;

$options = array(
    'consumer_key' => $consumer_key,
    'consumer_secret' => $consumer_secret,
    'callback' => $callback_url,
    'sendheaders' => true
);

$client = new Http;
$application = $this->getApplication();

$oauth = new OAuth($options, $client, $application->input, $application);

$twitter = new Twitter($oauth);

// Set the stored access token.
$oauth->setToken($token);

$access_token = $oauth->authenticate();

$users = $twitter->users->getUser($user);

use Joomla\Http\Http;
use Joomla\Twitter\Twitter;
use Joomla\Twitter\OAuth;

$token = array(
	'key' => "app_id",
	'secret' => "app_secret",
);
$my_url = 'http://localhost/twitter_test.php';

$options = array(
    'consumer_key' => $consumer_key,
    'consumer_secret' => $consumer_secret,
    'callback' => $callback_url,
    'sendheaders' => true
);

$client = new Http;
$application = $this->getApplication();

$oauth = new OAuth($options, $client, $application->input, $application);
$oauth->setToken($token);
$oauth->authenticate();

$twitter = new Twitter($oauth);

$statuses = $twitter->statuses;
$response = $statuses->tweet("The Twitter Package is amazing #joomla");