<?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]);

?>
