【发布时间】:2013-12-27 11:04:28
【问题描述】:
我收到以下行的此错误:
\Codebird\Codebird::setConsumerKey( $auth_args['consumer_key'], $auth_args['consumer_secret'] );
这是我刚刚安装在服务器上的 wordpress 模板。它适用于我的 WAMP 家庭服务器,但不适用于非自托管服务器。不确定是否是不同的 PHP 版本有问题。
这里是第 9 行:
class Jed_Widget_Latest_Tweets extends WP_Widget {
function __construct() {
parent::__construct(false, $name = 'Jednotka Twitter Widget', array( 'description' => 'Twitter profile widget for your site.' ) );
}
function retrieve_tweets( $widget_id, $instance, $auth_args ) {
if ( !empty($auth_args['consumer_key']) && !empty($auth_args['consumer_secret']) ) {
\Codebird\Codebird::setConsumerKey( $auth_args['consumer_key'], $auth_args['consumer_secret'] );
$cb = \Codebird\Codebird::getInstance();
$cb->setToken( $auth_args['access_token'], $auth_args['access_secret'] );
$timeline = $cb->statuses_userTimeline( 'screen_name=' . $instance['screen_name']. '&count=' . $instance['num_tweets'] . '&exclude_replies=true' );
return $timeline;
}
else {
return 'Authentication to twitter server failed. Please make sure that your "consumer key" and "consumer secret" are not empty';
}
}
function save_tweets( $widget_id, $instance, $auth_args ) {
$timeline = $this->retrieve_tweets( $widget_id, $instance, $auth_args );
$tweets = array( 'tweets' => $timeline, 'update_time' => time() + ( 60 * 5 ) );
update_option( 'my_tweets_' . $widget_id, $tweets );
return $tweets;
}
function get_tweets( $widget_id, $instance, $auth_args ) {
$tweets = get_option( 'my_tweets_' . $widget_id );
if( empty( $tweets ) OR time() > $tweets['update_time'] ) {
$tweets = $this->save_tweets( $widget_id, $instance, $auth_args );
}
return $tweets;
}
【问题讨论】:
-
我很确定你的问题是 PHP 版本。另一台服务器上的 PHP 版本可能不支持命名空间,所以它不知道如何处理反斜杠。
标签: php wordpress twitter syntax-error