PHP code example of cleytonbonamigo / share-twitter

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

    

cleytonbonamigo / share-twitter example snippets


use CleytonBonamigo\ShareTwitter\Client;

$settings = [
    'access_token' => access_token,
    'access_token' => access_token,
    'access_token_secret' => access_token_secret,
    'consumer_key' => consumer_key,
    'consumer_secret' => consumer_secret  
];

$client = new Client($settings);

$url = ''; //An URL or path to local file
$return = $client->media()->uploadMediaFromUrl($url);

$tweet = [
    'text' => 'Text of your tweet :)',
    'media' => [ //This param is optional
        'media_ids' => [
            'media_id_string' //Returned at uploadMediaFromUrl()
        ]
    ]
];

$client->tweet()->create(['text' => 'Test new tweet post with image complete flux', 'media' => ['media_ids' => [$media->media_id_string]]]);