PHP code example of legionth / serin
1. Go to this page and download the library: Download legionth/serin 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/ */
legionth / serin example snippets
useReact\EventLoop\Factory;
$oauthConsumerKey = 'SyCz6mFj7992Wy9tAcM1zQQci';
$consumerSecret = 'm349wE5VEkS3PM2FdS5eeptxoXz4o6jPHVyS1JVpGCZmYyPMqf';
$oauthToken = '3019738408-5wkZjXGk02TfyjWpMMolQHHdkQ3fr8APdkkTluk';
$tokenSecret = 'bo34Dph9tQGQC7cEk7ZBir5f9Du608FylevCAUwzw33sG';
$client = new \Legionth\Serin\Client(
$loop,
$oauthConsumerKey,
$consumerSecret,
$oauthToken,
$tokenSecret
);
$response = $client->tweet('does this work?');
$response->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
echo(\RingCentral\Psr7\str($exception->getResponse()));
});
$loop->run();
$response = $client->tweet('does this work?');
$responseSecondTweet = $client->tweet('of course it does');
$response->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
echo(\RingCentral\Psr7\str($exception->getResponse()));
});
$responseSecondTweet->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
echo(\RingCentral\Psr7\str($exception->getResponse()));
});
$client = new \Legionth\Serin\Client(
$loop,
$oauthConsumerKey,
$consumerSecret,
$oauthToken,
$tokenSecret
);
$request = new RingCentral\Psr7\ServerRequest(
'POST',
'https://api.twitter.com/1.1/statuses/update.json',
[ 'Content-Type' => 'application/x-www-form-urlencoded'],
'status=' . rawurlencode('Hello World'),
);
$response = $client->tweet($request);