0

我正在尝试运行一个脚本,该脚本每天更新一次我的 Twitter 帐户,说明距离某个日期还有多少天。我一直在使用此处概述的步骤,但尚未成功。该教程中使用的方法是否可能已过时?

我已经按照概述上传了 abrahams twitteroauth,这是我在 tweet.php 中使用的代码:

<?php

require_once('config.php');
require_once('twitteroauth/twitteroauth.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$today = idate('z', time());
$enddate = idate('z', strtotime('6 June 2013'));
$daysleft = $enddate - $today;

$tweetstr = 'Only ' . $daysleft . ' day';
if ($daysleft > 1) $tweetstr .= 's';
$tweetstr .= " left to this whatever event starts!";

$connection->post('statuses/update', array('status' => $tweetstr));

?>

我已将 twitter 应用程序设置为读取、写入和发送消息。我忽略了什么吗?我对 twitter api 相当陌生。

这是我运行脚本时出现的错误日志:

[Sat Feb 23 13:18:20 2013] [error] [client 86.40.89.186] PHP Notice:  Use of undefined constant ACCESS_TOKEN - assumed 'ACCESS_TOKEN' in /var/www/vhosts/darrenmccarra.com/connormccarra.com/lc-tweet-bot/lctweet45i32nd/tweet.php on line 5
[Sat Feb 23 13:18:20 2013] [error] [client 86.40.89.186] PHP Notice:  Use of undefined constant ACCESS_TOKEN_SECRET - assumed 'ACCESS_TOKEN_SECRET' in /var/www/vhosts/darrenmccarra.com/connormccarra.com/lc-tweet-bot/lctweet45i32nd/tweet.php on line 5
[Sat Feb 23 13:18:20 2013] [error] [client 86.40.89.186] PHP Warning:  idate() [<a href='function.idate'>function.idate</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead in /var/www/vhosts/darrenmccarra.com/connormccarra.com/lc-tweet-bot/lctweet45i32nd/tweet.php on line 6
[Sat Feb 23 13:18:20 2013] [error] [client 86.40.89.186] PHP Warning:  strtotime() [<a href='function.strtotime'>function.strtotime</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead in /var/www/vhosts/darrenmccarra.com/connormccarra.com/lc-tweet-bot/lctweet45i32nd/tweet.php on line 7
[Sat Feb 23 13:18:20 2013] [error] [client 86.40.89.186] PHP Warning:  idate() [<a href='function.idate'>function.idate</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead in /var/www/vhosts/darrenmccarra.com/connormccarra.com/lc-tweet-bot/lctweet45i32nd/tweet.php on line 7
4

0 回答 0