1. Go to this page and download the library: Download ricardoboss/webhook-tweeter 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/ */
ricardoboss / webhook-tweeter example snippets
use ricardoboss\WebhookTweeter\WebhookTweeterConfig;
use ricardoboss\WebhookTweeter\Simple\SimpleWebhookTweeterRenderer;
use ricardoboss\WebhookTweeter\Simple\SimpleWebhookTweeterTemplateLocator;
use ricardoboss\WebhookTweeter\WebhookTweeterHandler;
use ricardoboss\WebhookTweeter\API\BirdElephantTwitterAPI;
// 1. Create a config object
// you can also pass \Stringable objects instead of strings
$config = new WebhookTweeterConfig(
'webhook_url',
'webhook_secret' // nullable
);
// 2. Create an instance of WebhookTweeterRenderer
// either use your own renderer or use the simple renderer
$renderer = new SimpleWebhookTweeterRenderer();
// 3. Create a template locator instance
// the simple locator looks for files in the given directory and the given extension (name is passed to the getMatchingTemplate method)
$locator = new SimpleWebhookTweeterTemplateLocator(__DIR__ . '/templates', '.md');
// 4. Create a Twitter API client implementing WebhookTweeterTwitterAPI
$twitter = new BirdElephantTwitterAPI();
$twitter->setCredentials([
'bearer_token' => xxxxxx, // OAuth 2.0 Bearer Token requests
'consumer_key' => xxxxxx, // identifies your app, always needed
'consumer_secret' => xxxxxx, // app secret, always needed
'token_identifier' => xxxxxx, // OAuth 1.0a User Context requests
'token_secret' => xxxxxx, // OAuth 1.0a User Context requests
]);
// 5. Create a WebhookTweeterHandler instance
$handler = new WebhookTweeterHandler($config, $renderer, $locator, $twitter);
// 6. Get a PSR-7 request object
$request = /* get your request implementation */;
// 7. Handle the request (sends a rendered tweet)
$result = $handler->handle($request);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.