您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

78 行
2.0 KiB

<?php
// ---
// --- Listening to blockchain.info to get the last block
// --- Drawing the block as a Treemap
// --- Tweet it
// ---
// ---
// --- La config globale
// ---
require_once '../../global/inc/config.php';
// ---
// --- External dependances
// ---
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
// ---
// --- Internal dependances
// ---
require_once APP_PATH.'/blockchain/inc/block.php';
require 'inc/twitter.php';
$methode='spline';
if (isset($argv[3])) $methode=$argv[3];
$block_hash = $argv[1];
$the_block = blockchain::getBlockWithHash($block_hash);
if ($the_block === FALSE) die();
// ---
// --- Remercier les followers
// ---
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);
  $ratio = TWITTER_HEIGHT / imagesy($image_origine); 
  $new_width = $ratio * imagesx($image_origine);
  $xpos = floor((TWITTER_WIDTH - $new_width) / 2);
  $ypos = 0;
  imagecopyresized($image_twitter, $image_origine, $xpos, $ypos, 0, 0, $new_width, TWITTER_HEIGHT, imagesx($image_origine), imagesy($image_origine));
  $image_file = DATA_PATH."/twitterbot/".$argv[1].'.png';
  imagepng($image_twitter,$image_file);
  // ---
  // --- Un petit peu de stéganographie ...
  // ---
/* Ca fait des fichiers trop gros !
  $processor = new KzykHys\Steganography\Processor();
  $image = $processor->encode($image_file, 'TOPISTO is making art with block '.$the_block->height);
  $image->write($image_file);
*/
  // ---
  // --- Tweet
  // ---
  $tweet  = "#computerart : #bitcoin #blockchain 's".PHP_EOL;
  $tweet .= $argv[2]." Block, Height : ".$the_block->height.PHP_EOL;
  $tweet .= "[ See more on www.topisto.net ]";
  $success = twitter::tweet($tweet, $image_file);
}
?>