<?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;
  }

}

?>
