CentOS + PHP で Twitter bot を作成する(単発ツイート)

前回 CentOS で PHP を使って、ランダムにツイートする bot を作成する方法について書いた。

CentOS + PHP で Twitter bot を作成する(ランダムツイート) – with a Christian Wife
https://wacw.cf/2018/02/13/twitter-bot-withcentos-and-php/

では単純にツイートするだけの PHP も作ってみることにした。

といっても簡単で、前回の TwistOauth.phar と同じディレクトリに以下のような PHP ファイル(tweet.php とする)を作成し、$ php tweet.php と実行すればいい。

<?php
require 'TwistOauth.phar';

$consumer_key = 'xxxxxxxxxxxxxxxxx';
$consumer_secret = 'xxxxxxxxxxxxxxxxx';
$access_token = 'xxxxxxxxxxxxxxxxx';
$access_token_secret = 'xxxxxxxxxxxxxxxxx;

$connection = new TwistOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$connection->post('statuses/update', array('status' => 'おはよう。'));

参考:
自分磨き用bot作成 – 技術めも日記
http://nasuna.hateblo.jp/entry/2017/08/22/220215