我收到以下行的错误:
\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;
}
答案 0 :(得分:2)
确保您使用的是PHP 5.3或更高版本,并声明了命名空间,否则解释器会认为\ Codebird \ Codebird是一组随机字符