Twitter API ツイートする方法

投稿者: | 2016年12月27日

「TwistOAuth」を利用してTwitterでツイートする方法です


<?php

require_once (dirname(__FILE__) . '/lib/TwistOAuth-master/build/TwistOAuth.phar');

$consumer_key = '';
$consumer_secret = '';
$screen_name = '';
$password = '';
$text = '';

try {

   $to = TwistOAuth::login($consumer_key,
                           $consumer_secret, 
                           $screen_name, 
                           $password);

   $to->post('statuses/update', array('status' => $text)); 

} catch (TwistException $e) {

   echo $e->getMessage()."<BR>";

}

?>