| @ -4,6 +4,11 @@ use codeagent\treemap\Treemap; | |||
| use codeagent\treemap\presenter\ImagePresenter; | |||
| use codeagent\treemap\presenter\NodeInfo; | |||
| function tri($a, $b) { | |||
| if ($a['value'] == $b['value']) return 0; | |||
| return ($a['value'] < $b['value']) ? 1 : -1; | |||
| } | |||
| function DrawBlock($the_block, $vImage, $parametres) | |||
| { | |||
| $type = 1; | |||
| @ -30,6 +35,18 @@ function DrawBlock($the_block, $vImage, $parametres) | |||
| $data = blockchain::getTransactionData($the_block, $type); | |||
| usort($data, 'tri'); | |||
| $n=0; | |||
| $i=count($data)-1; | |||
| while($i>41) $n+=$data[$i--]['value']; | |||
| $n=intval(round(($n * 1.0) / count($data))); | |||
| $data = array_slice($data, 0, 41); | |||
| $data[] = ["hash" => "0000000000000000000000000000000000000000000000000000000000000000", "value" => $n]; | |||
| usort($data, 'tri'); | |||
| $treemap = new Treemap($data, $width, $height); | |||
| $map = $treemap->getMap(); | |||
| $m = count($map); | |||
| @ -1 +0,0 @@ | |||
| ["topisto42","UnnaxPayments","aureliusdrusus","solacedotcom","omgbtc","ohiobitcoin","LogicScience","redunisproject","Cryptocracy2020","fullstache","callblockapp","marketranger","TheCryptodamus","crypt0co","CryptoassetsUSA","Nadeem_nadi797","cryptomoneyz","BaseCyberSec","Tweetsintoabyss","anthkell98","grattonboy","mac_a_dam","devnullius","123wolfArmy","03018333860","JeffinkoGuru","BitJob_Team","rugigana","Crypto_info321","cointopic_","Chef_JeanPierre","Cienencom","btcltcdigger","AdzCoin_Gift","treyptrsn","n2yolo","SHL0M0ABADD0N","EdwardCulligan","promote_crypto","TheFutureShift","ErickCoval","RIMCorpPK","arhiezvanhoute1","ttoff85","actu_fintech","BeautyBubble","PDX_Trader","Yasirperdesi","cre8hyperledger","Thurse8","cre8capital","icobountyprogs","rob67803423","AphexTwin4ever"] | |||
| @ -1,324 +0,0 @@ | |||
| <?php | |||
| namespace Twifer; | |||
| class API | |||
| { | |||
| protected $consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret; | |||
| protected $apiUrl = 'https://api.twitter.com/'; | |||
| protected $apiStandardUrl = 'https://api.twitter.com/1.1/'; | |||
| protected $apiUploadUrl = 'https://upload.twitter.com/1.1/'; | |||
| protected $oauth = []; | |||
| public function __construct($consumer_key, $consumer_secret, $oauth_token = false, $oauth_token_secret = false) | |||
| { | |||
| $this->consumer_key = $consumer_key; | |||
| $this->consumer_secret = $consumer_secret; | |||
| $this->oauth_token = $oauth_token; | |||
| $this->oauth_token_secret = $oauth_token_secret; | |||
| if ($oauth_token == false && $oauth_token_secret == false) { | |||
| $this->oauth = [ | |||
| 'oauth_consumer_key' => $this->consumer_key, | |||
| 'oauth_nonce' => time(), | |||
| 'oauth_signature_method' => 'HMAC-SHA1', | |||
| 'oauth_timestamp' => time(), | |||
| 'oauth_version' => '1.0', | |||
| ]; | |||
| } elseif ($oauth_token !== false && $oauth_token_secret == false) { | |||
| $this->oauth = $oauth_token; | |||
| } else { | |||
| $this->oauth = [ | |||
| 'oauth_consumer_key' => $this->consumer_key, | |||
| 'oauth_nonce' => time(), | |||
| 'oauth_signature_method' => 'HMAC-SHA1', | |||
| 'oauth_token' => $this->oauth_token, | |||
| 'oauth_timestamp' => time(), | |||
| 'oauth_version' => '1.0', | |||
| ]; | |||
| } | |||
| } | |||
| protected function buildAutheaders($oauth) | |||
| { | |||
| $headers = 'Authorization: OAuth '; | |||
| $values = []; | |||
| foreach ($oauth as $key => $value) { | |||
| $values[] = "$key=\"" . rawurlencode($value) . "\""; | |||
| } | |||
| $headers .= implode(', ', $values); | |||
| return $headers; | |||
| } | |||
| protected function buildBearerheaders($oauth) | |||
| { | |||
| $headers = 'Authorization: Bearer ' . $oauth; | |||
| return $headers; | |||
| } | |||
| protected function buildString($method, $url, $params) | |||
| { | |||
| $headers = []; | |||
| ksort($params); | |||
| foreach ($params as $key => $value) { | |||
| $headers[] = "$key=" . rawurlencode($value); | |||
| } | |||
| return $method . "&" . rawurlencode($url) . '&' . rawurlencode(implode('&', $headers)); | |||
| } | |||
| protected function buildSignature($baseInfo) | |||
| { | |||
| $encodeKey = rawurlencode($this->consumer_secret) . '&' . rawurlencode($this->oauth_token_secret); | |||
| $oauthSignature = base64_encode(hash_hmac('sha1', $baseInfo, $encodeKey, true)); | |||
| return $oauthSignature; | |||
| } | |||
| protected function getSignature($method, $url, $params = false) | |||
| { | |||
| $oauth = $this->oauth; | |||
| if ($params == false) { | |||
| $baseInfo = $this->buildString($method, $url, $oauth); | |||
| $oauth['oauth_signature'] = $this->buildSignature($baseInfo); | |||
| } else { | |||
| $oauth = array_merge($oauth, $params); | |||
| $baseInfo = $this->buildString($method, $url, $oauth); | |||
| $oauth['oauth_signature'] = $this->buildSignature($baseInfo); | |||
| } | |||
| return $oauth; | |||
| } | |||
| protected function reqCurl($method = 'GET', $url, $params = false, $headers = false, $postfields = false, $userpwd = false) | |||
| { | |||
| $ch = curl_init(); | |||
| if ($params == false) { | |||
| curl_setopt($ch, CURLOPT_URL, $url); | |||
| } | |||
| if ($params == true) { | |||
| curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params)); | |||
| } | |||
| if ($method == 'POST') { | |||
| curl_setopt($ch, CURLOPT_POST, true); | |||
| } | |||
| if ($method == 'DELETE') { | |||
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); | |||
| } | |||
| if ($postfields == true) { | |||
| curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); | |||
| } | |||
| if ($headers == true) { | |||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |||
| } | |||
| if ($userpwd == true) { | |||
| curl_setopt($ch, CURLOPT_USERPWD, $this->consumer_key . ':' . $this->consumer_secret); | |||
| } | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |||
| $result = curl_exec($ch); | |||
| return $result; | |||
| } | |||
| protected function request2($method, $req, $params = false) | |||
| { | |||
| $req = substr($req, 1); | |||
| $url = $this->apiUrl . $req; | |||
| if ($this->oauth_token !== false && $this->oauth_token_secret == false) { | |||
| $oauth = $this->buildBearerheaders($this->oauth); | |||
| $headers = []; | |||
| $headers[] = $oauth; | |||
| } else { | |||
| $oauth = $this->getSignature($method, $url); | |||
| $headers = []; | |||
| $headers[] = 'Content-type: application/json'; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| } | |||
| $result = $this->reqCurl($method, $url, null, $headers, $params); | |||
| return json_decode($result, true); | |||
| } | |||
| public function request($method, $req, $params = false) | |||
| { | |||
| $method = strtoupper($method); | |||
| if ($req == 'media/upload') { | |||
| return $this->upload($method, $req, $params); | |||
| } | |||
| $version = explode('/', $req); | |||
| if ($version[0] == '2') { | |||
| $req = "/$req"; | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[1] == '2') { | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[0] == 'labs') { | |||
| $req = "/$req"; | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[1] == 'labs') { | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| $url = $this->apiStandardUrl . $req . ".json"; | |||
| if ($this->oauth_token !== false && $this->oauth_token_secret == false) { | |||
| $oauth = $this->buildBearerheaders($this->oauth); | |||
| $headers = []; | |||
| $headers[] = $oauth; | |||
| } else { | |||
| $oauth = $this->getSignature($method, $url, $params); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| } | |||
| $result = $this->reqCurl($method, $url, $params, $headers, null); | |||
| return json_decode($result, true); | |||
| } | |||
| protected function reqUpload($method, $req, $params) | |||
| { | |||
| $url = $this->apiUploadUrl . $req . ".json"; | |||
| $oauth = $this->getSignature($method, $url); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $headers[] = 'Content-Type: multipart/form-data'; | |||
| $result = $this->reqCurl($method, $url, null, $headers, $params); | |||
| return json_decode($result, true); | |||
| } | |||
| protected function uploadChunked($req, $params) | |||
| { | |||
| $_params = [ | |||
| 'command' => 'INIT', | |||
| 'total_bytes' => filesize($params['media']), | |||
| 'media_type' => $params['media_type'], | |||
| ]; | |||
| if (isset($params['additional_owners'])) { | |||
| $_params['additional_owners'] = $params['additional_owners']; | |||
| } | |||
| if (isset($params['media_category'])) { | |||
| $_params['media_category'] = $params['media_category']; | |||
| } | |||
| $req = $this->reqUpload('POST', 'media/upload', $_params); | |||
| $fp = fopen($params['media'], 'r'); | |||
| $segment_id = 0; | |||
| while (!feof($fp)) { | |||
| $chunk = fread($fp, 40960); | |||
| $__params = [ | |||
| "command" => "APPEND", | |||
| "media_id" => $req['media_id'], | |||
| "segment_index" => $segment_id++, | |||
| 'media_data' => base64_encode($chunk), | |||
| ]; | |||
| $this->reqUpload('POST', 'media/upload', $__params); | |||
| } | |||
| fclose($fp); | |||
| $lastParams = array( | |||
| "command" => "FINALIZE", | |||
| "media_id" => $req['media_id'], | |||
| ); | |||
| $result = $this->reqUpload('POST', 'media/upload', $lastParams); | |||
| return $result; | |||
| } | |||
| public function upload($method, $req, $params) | |||
| { | |||
| if ($method == 'GET') { | |||
| return "METHOD MUST BE POST"; | |||
| } | |||
| $url = $this->apiUploadUrl . $req . ".json"; | |||
| $c = count($params); | |||
| if ($c == 1 && isset($params['media'])) { | |||
| $filename = file_get_contents($params['media']); | |||
| $base64 = base64_encode($filename); | |||
| $_params = ['media_data' => $base64]; | |||
| return $this->reqUpload('POST', 'media/upload', $_params); | |||
| } elseif ($c == 1 && isset($params['media_data'])) { | |||
| $base64 = $params['media_data']; | |||
| $_params = ['media_data' => $base64]; | |||
| return $this->reqUpload('POST', 'media/upload', $_params); | |||
| } else { | |||
| return $this->uploadChunked($req, $params); | |||
| } | |||
| } | |||
| public function file($oauthUrl) | |||
| { | |||
| $oauth = $this->getSignature("GET", $oauthUrl); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $result = $this->reqCurl("GET", $oauthUrl, null, $headers, null); | |||
| return $result; | |||
| } | |||
| public function oauth($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req; | |||
| $oauth = $this->getSignature("POST", $url, $params); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $result = $this->reqCurl("POST", $url, $params, $headers, null); | |||
| parse_str($result, $arr); | |||
| return $arr; | |||
| } | |||
| public function url($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req . "?" . http_build_query($params); | |||
| return $url; | |||
| } | |||
| public function oauth2($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req; | |||
| $result = $this->reqCurl("POST", $url, $params, null, null, true); | |||
| return json_decode($result, true); | |||
| } | |||
| } | |||
| @ -1,14 +0,0 @@ | |||
| <?php | |||
| /* TOPISTO */ | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| // Client ID | |||
| // TE5jWFRIVTZVQkdnT2FIeEJyYTY6MTpjaQ | |||
| // Client Secret | |||
| // GyZkEE69j0UPPKfmal9tT287-ZVw7vQbV20qvDPTFLCgNOplUk | |||
| ?> | |||
| @ -1,88 +0,0 @@ | |||
| <?php | |||
| use Abraham\TwitterOAuth\TwitterOAuth; | |||
| // Twitter OAuth Settings: | |||
| /* TOPISTO */ | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| /* R. Topisto | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| */ | |||
| define('TWITTER_WIDTH', 880); | |||
| define('TWITTER_HEIGHT', 440); | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array("status" => $message); | |||
| if (($media != NULL)&&($media != '')) | |||
| { | |||
| $imageMedia = $twitter->upload('media/upload', array('media' => $media)); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array( | |||
| "status" => $message, | |||
| "media_ids" => $imageMedia->media_id_string); | |||
| } | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('statuses/retweets_of_me'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| /* TO DO */ | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('followers/list'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $followers = json_decode(file_get_contents('followers.json')); | |||
| foreach($results->users as $user) | |||
| if (!in_array($user->screen_name, $followers)) | |||
| { | |||
| $parameters = array("status" => '@'.$user->screen_name.' thanks following me !'); | |||
| $followers[] = $user->screen_name; | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| break; // Un à la fois ... | |||
| } | |||
| file_put_contents('followers.json', json_encode($followers)); | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,42 +0,0 @@ | |||
| <?php | |||
| require 'twifer.php'; | |||
| use Twifer\API; | |||
| /* TOPISTO */ | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new API(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $filename = '0000000000000000000034a2ed514ecda92b8b88593b0bc8e6ffffc978721c25.png'; | |||
| //$img = $twitter->request('POST', 'media/upload', ['media' => $filename]); | |||
| $media_id='1739965196775346176'; | |||
| $postfields = "{\"text\":\"$message\", \"media\": {\"media_ids\": [\"$media_id\"]}}"; | |||
| $res = $twitter->request('POST', '/2/tweets', $postfields); | |||
| print_r($res); | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,7 +0,0 @@ | |||
| <?php | |||
| require 'twitter2.php'; | |||
| twitter::tweet('TOPISTO test API V2'); | |||
| ?> | |||
| @ -1,83 +0,0 @@ | |||
| <?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'; | |||
| require '../generique/inc/twitter.php'; | |||
| $midnight = strtotime('today midnight'); | |||
| $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."/emptybot/".$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 = "Lucky One on #bitcoin #blockchain 's".PHP_EOL; | |||
| $tweet .= "Someone put an empty block ...".PHP_EOL; | |||
| $tweet .= "And get the reward for it !".PHP_EOL; | |||
| $tweet .= "Block height : ".$the_block->height.PHP_EOL; | |||
| $tweet .= "[ See more on www.topisto.net ]"; | |||
| $success = twitter::tweet($tweet, $image_file); | |||
| } | |||
| ?> | |||
| @ -1,38 +0,0 @@ | |||
| #!/bin/bash | |||
| flag=$TMP_PATH/emptybot_bot.flag | |||
| if [ -f $flag ]; | |||
| then | |||
| echo "empty_bot is already running !" | |||
| exit 0 | |||
| fi | |||
| touch $flag | |||
| cd $APPS_PATH/twitter/emptybot | |||
| # | |||
| # Se lancer pour un tweet sur un block unique | |||
| # | |||
| BLOCK_LINE=`grep LAST $DATA_PATH/block_list.txt` | |||
| BLOCK_HASH=`echo ${BLOCK_LINE} | awk '{print $2}'` | |||
| BLOCK_NAME=`echo ${BLOCK_LINE} | awk '{print $1}'` | |||
| BLOCK_HEIGHT=`echo ${BLOCK_LINE} | awk '{print $3}'` | |||
| BLOCK_SIZE=`echo ${BLOCK_LINE} | awk '{print $4}'` | |||
| if [ $BLOCK_SIZE -eq 1 ] | |||
| then | |||
| if [ -f $DATA_PATH/hasard/$BLOCK_HASH.png ] | |||
| then | |||
| if [ ! -f $DATA_PATH/emptybot/$BLOCK_HASH.png ] | |||
| then | |||
| echo Tweet EmptyBlock for $BLOCK_HASH | |||
| echo $BLOCK_LINE >> $DATA_PATH/emptybot/list.txt | |||
| php robot.php $BLOCK_HASH $BLOCK_NAME hasard $BLOCK_HEIGHT | |||
| # Don't TWEET it again ... | |||
| touch $DATA_PATH/twitterbot/$BLOCK_HASH | |||
| fi | |||
| fi | |||
| fi | |||
| rm -f $flag | |||
| @ -1,324 +0,0 @@ | |||
| <?php | |||
| namespace Twifer; | |||
| class API | |||
| { | |||
| protected $consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret; | |||
| protected $apiUrl = 'https://api.twitter.com/'; | |||
| protected $apiStandardUrl = 'https://api.twitter.com/1.1/'; | |||
| protected $apiUploadUrl = 'https://upload.twitter.com/1.1/'; | |||
| protected $oauth = []; | |||
| public function __construct($consumer_key, $consumer_secret, $oauth_token = false, $oauth_token_secret = false) | |||
| { | |||
| $this->consumer_key = $consumer_key; | |||
| $this->consumer_secret = $consumer_secret; | |||
| $this->oauth_token = $oauth_token; | |||
| $this->oauth_token_secret = $oauth_token_secret; | |||
| if ($oauth_token == false && $oauth_token_secret == false) { | |||
| $this->oauth = [ | |||
| 'oauth_consumer_key' => $this->consumer_key, | |||
| 'oauth_nonce' => time(), | |||
| 'oauth_signature_method' => 'HMAC-SHA1', | |||
| 'oauth_timestamp' => time(), | |||
| 'oauth_version' => '1.0', | |||
| ]; | |||
| } elseif ($oauth_token !== false && $oauth_token_secret == false) { | |||
| $this->oauth = $oauth_token; | |||
| } else { | |||
| $this->oauth = [ | |||
| 'oauth_consumer_key' => $this->consumer_key, | |||
| 'oauth_nonce' => time(), | |||
| 'oauth_signature_method' => 'HMAC-SHA1', | |||
| 'oauth_token' => $this->oauth_token, | |||
| 'oauth_timestamp' => time(), | |||
| 'oauth_version' => '1.0', | |||
| ]; | |||
| } | |||
| } | |||
| protected function buildAutheaders($oauth) | |||
| { | |||
| $headers = 'Authorization: OAuth '; | |||
| $values = []; | |||
| foreach ($oauth as $key => $value) { | |||
| $values[] = "$key=\"" . rawurlencode($value) . "\""; | |||
| } | |||
| $headers .= implode(', ', $values); | |||
| return $headers; | |||
| } | |||
| protected function buildBearerheaders($oauth) | |||
| { | |||
| $headers = 'Authorization: Bearer ' . $oauth; | |||
| return $headers; | |||
| } | |||
| protected function buildString($method, $url, $params) | |||
| { | |||
| $headers = []; | |||
| ksort($params); | |||
| foreach ($params as $key => $value) { | |||
| $headers[] = "$key=" . rawurlencode($value); | |||
| } | |||
| return $method . "&" . rawurlencode($url) . '&' . rawurlencode(implode('&', $headers)); | |||
| } | |||
| protected function buildSignature($baseInfo) | |||
| { | |||
| $encodeKey = rawurlencode($this->consumer_secret) . '&' . rawurlencode($this->oauth_token_secret); | |||
| $oauthSignature = base64_encode(hash_hmac('sha1', $baseInfo, $encodeKey, true)); | |||
| return $oauthSignature; | |||
| } | |||
| protected function getSignature($method, $url, $params = false) | |||
| { | |||
| $oauth = $this->oauth; | |||
| if ($params == false) { | |||
| $baseInfo = $this->buildString($method, $url, $oauth); | |||
| $oauth['oauth_signature'] = $this->buildSignature($baseInfo); | |||
| } else { | |||
| $oauth = array_merge($oauth, $params); | |||
| $baseInfo = $this->buildString($method, $url, $oauth); | |||
| $oauth['oauth_signature'] = $this->buildSignature($baseInfo); | |||
| } | |||
| return $oauth; | |||
| } | |||
| protected function reqCurl($method = 'GET', $url, $params = false, $headers = false, $postfields = false, $userpwd = false) | |||
| { | |||
| $ch = curl_init(); | |||
| if ($params == false) { | |||
| curl_setopt($ch, CURLOPT_URL, $url); | |||
| } | |||
| if ($params == true) { | |||
| curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params)); | |||
| } | |||
| if ($method == 'POST') { | |||
| curl_setopt($ch, CURLOPT_POST, true); | |||
| } | |||
| if ($method == 'DELETE') { | |||
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); | |||
| } | |||
| if ($postfields == true) { | |||
| curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); | |||
| } | |||
| if ($headers == true) { | |||
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |||
| } | |||
| if ($userpwd == true) { | |||
| curl_setopt($ch, CURLOPT_USERPWD, $this->consumer_key . ':' . $this->consumer_secret); | |||
| } | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |||
| $result = curl_exec($ch); | |||
| return $result; | |||
| } | |||
| protected function request2($method, $req, $params = false) | |||
| { | |||
| $req = substr($req, 1); | |||
| $url = $this->apiUrl . $req; | |||
| if ($this->oauth_token !== false && $this->oauth_token_secret == false) { | |||
| $oauth = $this->buildBearerheaders($this->oauth); | |||
| $headers = []; | |||
| $headers[] = $oauth; | |||
| } else { | |||
| $oauth = $this->getSignature($method, $url); | |||
| $headers = []; | |||
| $headers[] = 'Content-type: application/json'; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| } | |||
| $result = $this->reqCurl($method, $url, null, $headers, $params); | |||
| return json_decode($result, true); | |||
| } | |||
| public function request($method, $req, $params = false) | |||
| { | |||
| $method = strtoupper($method); | |||
| if ($req == 'media/upload') { | |||
| return $this->upload($method, $req, $params); | |||
| } | |||
| $version = explode('/', $req); | |||
| if ($version[0] == '2') { | |||
| $req = "/$req"; | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[1] == '2') { | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[0] == 'labs') { | |||
| $req = "/$req"; | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| if ($version[1] == 'labs') { | |||
| return $this->request2($method, $req, $params); | |||
| } | |||
| $url = $this->apiStandardUrl . $req . ".json"; | |||
| if ($this->oauth_token !== false && $this->oauth_token_secret == false) { | |||
| $oauth = $this->buildBearerheaders($this->oauth); | |||
| $headers = []; | |||
| $headers[] = $oauth; | |||
| } else { | |||
| $oauth = $this->getSignature($method, $url, $params); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| } | |||
| $result = $this->reqCurl($method, $url, $params, $headers, null); | |||
| return json_decode($result, true); | |||
| } | |||
| protected function reqUpload($method, $req, $params) | |||
| { | |||
| $url = $this->apiUploadUrl . $req . ".json"; | |||
| $oauth = $this->getSignature($method, $url); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $headers[] = 'Content-Type: multipart/form-data'; | |||
| $result = $this->reqCurl($method, $url, null, $headers, $params); | |||
| return json_decode($result, true); | |||
| } | |||
| protected function uploadChunked($req, $params) | |||
| { | |||
| $_params = [ | |||
| 'command' => 'INIT', | |||
| 'total_bytes' => filesize($params['media']), | |||
| 'media_type' => $params['media_type'], | |||
| ]; | |||
| if (isset($params['additional_owners'])) { | |||
| $_params['additional_owners'] = $params['additional_owners']; | |||
| } | |||
| if (isset($params['media_category'])) { | |||
| $_params['media_category'] = $params['media_category']; | |||
| } | |||
| $req = $this->reqUpload('POST', 'media/upload', $_params); | |||
| $fp = fopen($params['media'], 'r'); | |||
| $segment_id = 0; | |||
| while (!feof($fp)) { | |||
| $chunk = fread($fp, 40960); | |||
| $__params = [ | |||
| "command" => "APPEND", | |||
| "media_id" => $req['media_id'], | |||
| "segment_index" => $segment_id++, | |||
| 'media_data' => base64_encode($chunk), | |||
| ]; | |||
| $this->reqUpload('POST', 'media/upload', $__params); | |||
| } | |||
| fclose($fp); | |||
| $lastParams = array( | |||
| "command" => "FINALIZE", | |||
| "media_id" => $req['media_id'], | |||
| ); | |||
| $result = $this->reqUpload('POST', 'media/upload', $lastParams); | |||
| return $result; | |||
| } | |||
| public function upload($method, $req, $params) | |||
| { | |||
| if ($method == 'GET') { | |||
| return "METHOD MUST BE POST"; | |||
| } | |||
| $url = $this->apiUploadUrl . $req . ".json"; | |||
| $c = count($params); | |||
| if ($c == 1 && isset($params['media'])) { | |||
| $filename = file_get_contents($params['media']); | |||
| $base64 = base64_encode($filename); | |||
| $_params = ['media_data' => $base64]; | |||
| return $this->reqUpload('POST', 'media/upload', $_params); | |||
| } elseif ($c == 1 && isset($params['media_data'])) { | |||
| $base64 = $params['media_data']; | |||
| $_params = ['media_data' => $base64]; | |||
| return $this->reqUpload('POST', 'media/upload', $_params); | |||
| } else { | |||
| return $this->uploadChunked($req, $params); | |||
| } | |||
| } | |||
| public function file($oauthUrl) | |||
| { | |||
| $oauth = $this->getSignature("GET", $oauthUrl); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $result = $this->reqCurl("GET", $oauthUrl, null, $headers, null); | |||
| return $result; | |||
| } | |||
| public function oauth($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req; | |||
| $oauth = $this->getSignature("POST", $url, $params); | |||
| $headers = []; | |||
| $headers[] = $this->buildAutheaders($oauth); | |||
| $result = $this->reqCurl("POST", $url, $params, $headers, null); | |||
| parse_str($result, $arr); | |||
| return $arr; | |||
| } | |||
| public function url($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req . "?" . http_build_query($params); | |||
| return $url; | |||
| } | |||
| public function oauth2($req, $params) | |||
| { | |||
| $url = $this->apiUrl . $req; | |||
| $result = $this->reqCurl("POST", $url, $params, null, null, true); | |||
| return json_decode($result, true); | |||
| } | |||
| } | |||
| @ -1,39 +0,0 @@ | |||
| <?php | |||
| require '../../generique/inc/twifer.php'; | |||
| use Twifer\API; | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new API(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $filename = '0000000000000000000034a2ed514ecda92b8b88593b0bc8e6ffffc978721c25.png'; | |||
| $media_id='1739965196775346176'; | |||
| if (($media != NULL)&&($media != '')){ | |||
| $img = $twitter->request('POST', 'media/upload', ['media' => $media]); | |||
| $media_id=$img['media_id']; | |||
| } | |||
| $postfields = "{\"text\":\"$message\", \"media\": {\"media_ids\": [\"$media_id\"]}}"; | |||
| $res = $twitter->request('POST', '/2/tweets', $postfields); | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,88 +0,0 @@ | |||
| <?php | |||
| use Abraham\TwitterOAuth\TwitterOAuth; | |||
| // Twitter OAuth Settings: | |||
| /* TOPISTO */ | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| /* R. Topisto | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| */ | |||
| define('TWITTER_WIDTH', 880); | |||
| define('TWITTER_HEIGHT', 440); | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array("status" => $message); | |||
| if (($media != NULL)&&($media != '')) | |||
| { | |||
| $imageMedia = $twitter->upload('media/upload', array('media' => $media)); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array( | |||
| "status" => $message, | |||
| "media_ids" => $imageMedia->media_id_string); | |||
| } | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('statuses/retweets_of_me'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| /* TO DO */ | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('followers/list'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $followers = json_decode(file_get_contents('followers.json')); | |||
| foreach($results->users as $user) | |||
| if (!in_array($user->screen_name, $followers)) | |||
| { | |||
| $parameters = array("status" => '@'.$user->screen_name.' thanks following me !'); | |||
| $followers[] = $user->screen_name; | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| break; // Un à la fois ... | |||
| } | |||
| file_put_contents('followers.json', json_encode($followers)); | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,42 +0,0 @@ | |||
| <?php | |||
| require 'twifer.php'; | |||
| use Twifer\API; | |||
| /* TOPISTO */ | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new API(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $filename = '0000000000000000000034a2ed514ecda92b8b88593b0bc8e6ffffc978721c25.png'; | |||
| //$img = $twitter->request('POST', 'media/upload', ['media' => $filename]); | |||
| $media_id='1739965196775346176'; | |||
| $postfields = "{\"text\":\"$message\", \"media\": {\"media_ids\": [\"$media_id\"]}}"; | |||
| $res = $twitter->request('POST', '/2/tweets', $postfields); | |||
| print_r($res); | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,7 +0,0 @@ | |||
| <?php | |||
| require 'twitter2.php'; | |||
| twitter::tweet('TOPISTO test API V2'); | |||
| ?> | |||
| @ -1,50 +0,0 @@ | |||
| <?php | |||
| // --- | |||
| // --- Get last R. Topisto 's tweet | |||
| // --- Send a LIKE or ReTweet it. | |||
| // --- | |||
| // --- | |||
| // --- La config globale | |||
| // --- | |||
| require_once '../../global/inc/config.php'; | |||
| // --- | |||
| // --- External dependances | |||
| // --- | |||
| require TOPISTO_PATH.'/ressources/vendor/autoload.php'; | |||
| use Abraham\TwitterOAuth\TwitterOAuth; | |||
| // Twitter OAuth Settings: | |||
| /* TOPISTO | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| */ | |||
| /* R. Topisto */ | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $theSearch = [ | |||
| 'screen_name' => 'r_topisto', | |||
| 'count' => 1 | |||
| ]; | |||
| // --- | |||
| // --- envoi d'un LIKE | |||
| // --- | |||
| $results = $twitter->get('users/show', $theSearch); | |||
| $twitter->post('favorites/create', ['id' => $results->status->id_str]); | |||
| ?> | |||
| @ -1,19 +0,0 @@ | |||
| #!/bin/bash | |||
| flag=$TMP_PATH/topisto_bot.flag | |||
| if [ -f $flag ]; | |||
| then | |||
| echo "likebot_bot is already running !" | |||
| exit 0 | |||
| fi | |||
| touch $flag | |||
| cd $APPS_PATH/twitter/likebot | |||
| if [ 4 -gt $((RANDOM % 100)) ] | |||
| then | |||
| php topisto.php | |||
| fi | |||
| rm -f $flag | |||
| @ -1 +0,0 @@ | |||
| ["CryptoPressNews","ryushi_w","JoelPlatoon","JavierTomeo_","Baythuglife"] | |||
| @ -1 +0,0 @@ | |||
| ["topisto42","UnnaxPayments","aureliusdrusus","solacedotcom","omgbtc","ohiobitcoin","LogicScience","redunisproject","Cryptocracy2020","fullstache","callblockapp","marketranger","TheCryptodamus","crypt0co","CryptoassetsUSA","Nadeem_nadi797","cryptomoneyz","BaseCyberSec","Tweetsintoabyss","anthkell98","grattonboy","mac_a_dam","devnullius","123wolfArmy","03018333860","JeffinkoGuru","BitJob_Team","rugigana","Crypto_info321","cointopic_","Chef_JeanPierre","Cienencom","btcltcdigger","AdzCoin_Gift","treyptrsn","n2yolo","SHL0M0ABADD0N","EdwardCulligan","promote_crypto","TheFutureShift","ErickCoval","RIMCorpPK","arhiezvanhoute1","ttoff85","actu_fintech","BeautyBubble","PDX_Trader","Yasirperdesi","cre8hyperledger","Thurse8","cre8capital","icobountyprogs","rob67803423","AphexTwin4ever"] | |||
| @ -1,14 +0,0 @@ | |||
| <?php | |||
| /* R. Topisto */ | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| // Client ID | |||
| // bjhuSFhSOExJc1Z2aG91ZXN3ZDk6MTpjaQ | |||
| // Client Secret | |||
| // ICMEoR-soYXA8Xut6a1kF8aOEq2qm0cMu7vDEivL15w_D0YVvx | |||
| ?> | |||
| @ -1,88 +0,0 @@ | |||
| <?php | |||
| use Abraham\TwitterOAuth\TwitterOAuth; | |||
| // Twitter OAuth Settings: | |||
| /* TOPISTO | |||
| define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO'); | |||
| define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8'); | |||
| define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe'); | |||
| define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd'); | |||
| */ | |||
| /* R. Topisto */ | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| define('TWITTER_WIDTH', 880); | |||
| define('TWITTER_HEIGHT', 440); | |||
| class twitter | |||
| { | |||
| public static function tweet($message, $media='') | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array("status" => $message); | |||
| if (($media != NULL)&&($media != '')) | |||
| { | |||
| $imageMedia = $twitter->upload('media/upload', array('media' => $media)); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $parameters = array( | |||
| "status" => $message, | |||
| "media_ids" => $imageMedia->media_id_string); | |||
| } | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| return TRUE; | |||
| } | |||
| public static function thanksRetweet() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('statuses/retweets_of_me'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| /* TO DO */ | |||
| return TRUE; | |||
| } | |||
| public static function thanksFollowers() | |||
| { | |||
| $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |||
| $content = $twitter->get('account/verify_credentials'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $results = $twitter->get('followers/list'); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| $followers = json_decode(file_get_contents('followers.json')); | |||
| foreach($results->users as $user) | |||
| if (!in_array($user->screen_name, $followers)) | |||
| { | |||
| $parameters = array("status" => '@'.$user->screen_name.' thanks following me !'); | |||
| $followers[] = $user->screen_name; | |||
| $statuses = $twitter->post("statuses/update", $parameters); | |||
| if ($twitter->getLastHttpCode() !== 200) return FALSE; | |||
| break; // Un à la fois ... | |||
| } | |||
| file_put_contents('followers.json', json_encode($followers)); | |||
| return TRUE; | |||
| } | |||
| } | |||
| ?> | |||
| @ -1,14 +0,0 @@ | |||
| <?php | |||
| /* R. Topisto */ | |||
| define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm'); | |||
| define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2'); | |||
| define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8'); | |||
| define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls'); | |||
| // Client ID | |||
| // TE5jWFRIVTZVQkdnT2FIeEJyYTY6MTpjaQ | |||
| // Client Secret | |||
| // GyZkEE69j0UPPKfmal9tT287-ZVw7vQbV20qvDPTFLCgNOplUk | |||
| ?> | |||
| @ -1,78 +0,0 @@ | |||
| <?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'; | |||
| require '../generique/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); | |||
| 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 #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 ]"; | |||
| $success = twitter::tweet($tweet, $image_file); | |||
| } | |||
| ?> | |||
| @ -1,66 +0,0 @@ | |||
| #!/bin/bash | |||
| flag=$TMP_PATH/twitterbot_bot.flag | |||
| if [ -f $flag ]; | |||
| then | |||
| echo "twitter_bot is already running !" | |||
| exit 0 | |||
| fi | |||
| touch $flag | |||
| cd $APPS_PATH/twitter/twitterbot | |||
| # | |||
| # Tweet pour un assemblage de hash | |||
| # | |||
| for fichier in `ls -tr $DATA_PATH/hashes2hashes/*.png` | |||
| do | |||
| BLOCK_HASH=`basename $fichier .png` | |||
| done | |||
| if [ 5 -gt $((RANDOM % 100)) ] | |||
| then | |||
| php robot.php $BLOCK_HASH CONFIRMED hashes2hashes | |||
| touch $DATA_PATH/twitterbot/$BLOCK_HASH | |||
| fi | |||
| # | |||
| # Se lancer pour un tweet sur un block unique | |||
| # | |||
| BLOCK_LINE=`tail -n 1 $DATA_PATH/block_list.txt` | |||
| BLOCK_HASH=`echo ${BLOCK_LINE} | awk '{print $2}'` | |||
| BLOCK_NAME=`echo ${BLOCK_LINE} | awk '{print $1}'` | |||
| BLOCK_HEIGHT=`echo ${BLOCK_LINE} | awk '{print $3}'` | |||
| # | |||
| # Dans 5% des cas, on tweet un bloc remarquable | |||
| # à la place du LAST | |||
| # | |||
| if [ 5 -gt $((RANDOM % 100)) ] | |||
| then | |||
| BLOCK_LINE=`grep -v $BLOCK_NAME $DATA_PATH/block_list.txt | shuf | head -n 1` | |||
| BLOCK_HASH=`echo ${BLOCK_LINE} | awk '{print $2}'` | |||
| BLOCK_NAME=`echo ${BLOCK_LINE} | awk '{print $1}'` | |||
| BLOCK_HEIGHT=`echo ${BLOCK_LINE} | awk '{print $3}'` | |||
| fi | |||
| if [ -f $DATA_PATH/hasard/$BLOCK_HASH.png ] | |||
| then | |||
| if [ ! -f $DATA_PATH/twitterbot/$BLOCK_HASH ] | |||
| then | |||
| echo Tweet for $BLOCK_HASH $BLOCK_NAME | |||
| php robot.php $BLOCK_HASH $BLOCK_NAME hasard $BLOCK_HEIGHT | |||
| # | |||
| # On met un marqueur pour ne pas retweeter | |||
| # plusieurs fois le LAST | |||
| # | |||
| if [[ "$BLOCK_NAME" == "LAST" ]] | |||
| then | |||
| touch $DATA_PATH/twitterbot/$BLOCK_HASH | |||
| fi | |||
| fi | |||
| fi | |||
| rm -f $flag | |||
| @ -1,78 +0,0 @@ | |||
| <?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 #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 ]"; | |||
| $success = twitter::tweet($tweet, $image_file); | |||
| } | |||
| ?> | |||