🎉 Hello world

This commit is contained in:
2021-02-26 13:17:32 +01:00
commit bcb51718d5
8 changed files with 1768 additions and 0 deletions

39
bot.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
use Abraham\TwitterOAuth\TwitterOAuth;
use Abraham\TwitterOAuth\TwitterOAuthException;
use Shikiryu\WebGobbler\Assembler\Superpose;
use Shikiryu\WebGobbler\Config;
use Shikiryu\WebGobbler\Pool;
include 'vendor/autoload.php';
$twitter_config = require 'config.php';
try {
// generate picture
$config = new Config('./config.json');
$pool = new Pool($config);
$upload_image_name = uniqid('superpose_', true);
$image = new Superpose($pool, $config);
$image->saveTo(sprintf('./render/%s.jpg', $upload_image_name));
// send picture to twitter
$connection = new TwitterOAuth(
$twitter_config['api_key'],
$twitter_config['api_secret'],
$twitter_config['access_token'],
$twitter_config['access_secret']
);
$connection->setTimeouts(5, 60000);
$collage = $connection->upload('media/upload', ['media' => realpath(sprintf('./render/%s.jpg', $upload_image_name))]);
$parameters = [
'status' => 'Nouveau collage',
'media_ids' => $collage->media_id_string,
];
$result = $connection->post('statuses/update', $parameters);
} catch (TwitterOAuthException | Exception $exception) {
echo $exception->getMessage();
}