202312 - Twitter API v2
This commit is contained in:
@@ -21,6 +21,8 @@ require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
||||
// ---
|
||||
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||
require 'inc/twitter.php';
|
||||
require '../generique/inc/twitter.php';
|
||||
require '../config.php';
|
||||
|
||||
$methode='spline';
|
||||
if (isset($argv[3])) $methode=$argv[3];
|
||||
@@ -32,30 +34,35 @@ if ($the_block === FALSE) die();
|
||||
// ---
|
||||
// --- Remercier les followers
|
||||
// ---
|
||||
twitter::thanksFollowers();
|
||||
// twitter::thanksFollowers();
|
||||
|
||||
$image_file=DATA_PATH."/$methode/".$argv[1].'.png';
|
||||
|
||||
if (file_exists($image_file))
|
||||
{
|
||||
$image_origine = imagecreatefrompng($image_file);
|
||||
$image_twitter = imagecreatetruecolor(TWITTER_WIDTH, TWITTER_HEIGHT);
|
||||
|
||||
$fond = imagecolorallocate($image_twitter, 255, 255, 255);
|
||||
//imagecolortransparent($image_twitter, $fond);
|
||||
imagefilledrectangle($image_twitter, 0, 0, TWITTER_WIDTH, TWITTER_HEIGHT, $fond);
|
||||
if (image_origine) {
|
||||
$image_twitter = imagecreatetruecolor(TWITTER_WIDTH, TWITTER_HEIGHT);
|
||||
if ($image_twitter) {
|
||||
|
||||
$ratio = TWITTER_HEIGHT / imagesy($image_origine);
|
||||
$new_width = $ratio * imagesx($image_origine);
|
||||
$fond = imagecolorallocate($image_twitter, 0, 0, 0);
|
||||
imagefilledrectangle($image_twitter, 0, 0, TWITTER_WIDTH, TWITTER_HEIGHT, $fond);
|
||||
|
||||
$xpos = floor((TWITTER_WIDTH - $new_width) / 2);
|
||||
$ypos = 0;
|
||||
$ratio = TWITTER_HEIGHT / imagesy($image_origine);
|
||||
$new_width = $ratio * imagesx($image_origine);
|
||||
|
||||
imagecopyresized($image_twitter, $image_origine, $xpos, $ypos, 0, 0, $new_width, TWITTER_HEIGHT, imagesx($image_origine), imagesy($image_origine));
|
||||
$xpos = floor((TWITTER_WIDTH - $new_width) / 2);
|
||||
$ypos = 0;
|
||||
|
||||
$image_file = DATA_PATH."/twitterbot/".$argv[1].'.png';
|
||||
imagecopyresized($image_twitter, $image_origine, $xpos, $ypos, 0, 0, $new_width, TWITTER_HEIGHT, imagesx($image_origine), imagesy($image_origine));
|
||||
|
||||
imagepng($image_twitter,$image_file);
|
||||
$image_file = DATA_PATH."/twitterbot/".$argv[1].'.png';
|
||||
|
||||
if (!imagepng($image_twitter,$image_file)) $image_file='';
|
||||
|
||||
} else echo("Pbme avec image TWITTER ".PHP_EOL);
|
||||
} else echo("Pbme avec $image_file ".PHP_EOL);
|
||||
|
||||
// ---
|
||||
// --- Un petit peu de stéganographie ...
|
||||
@@ -69,9 +76,9 @@ if (file_exists($image_file))
|
||||
// ---
|
||||
// --- Tweet
|
||||
// ---
|
||||
$tweet = "#computerart #creativecoding #generativeart :".PHP_EOL."#bitcoin #blockchain 's".PHP_EOL;
|
||||
$tweet .= $argv[2]." Block, Height : ".$the_block->height.PHP_EOL;
|
||||
$tweet .= "[ See more on www.topisto.net ]";
|
||||
$tweet = "#computerart #creativecoding #generativeart :\\n#bitcoin #blockchain \\n";
|
||||
$tweet .= $argv[2]." Block, Height : ".$the_block->height;
|
||||
$tweet .= "\\n[ See more on www.topisto.net ]";
|
||||
$success = twitter::tweet($tweet, $image_file);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user