TwitterOAuth.php不会运行'use'



错误是:

解析错误:语法错误,意外的'use' (T_USE)在/Applications/MAMP/htdocs/wp-content/plugins/plugin-name/includes/display-functions.php第9行

require_once "twitteroauth/autoload.php";
use AbrahamTwitterOAuthTwitterOAuth;    //<--this is line 9 where the error occurs
$consumerkey = '***************';
$consumersecret = '*********************************************';
$accesstoken = '*********************************************';
$accesstokensecret = '******************************';
$connection = new TwitterOAuth($consumerkey, $consumersecret ,$accesstoken, $accesstokensecret);
$statues = $connection->get("statuses/home_timeline", array("count" => 25, "exclude_replies" => true));

我是偶然发现的。

我还没能弄清楚为什么它不工作,但管理了一个简单的解决方案。

工作代码:

require_once "twitteroauth/autoload.php";
//use AbrahamTwitterOAuthTwitterOAuth;    //<--this is line 9 where the error occurs
$consumerkey = '***************';
$consumersecret = '*********************************************';
$accesstoken = '*********************************************';
$accesstokensecret = '******************************';
$connection = new AbrahamTwitterOAuthTwitterOAuth($consumerkey, $consumersecret ,$accesstoken, $accesstokensecret);

希望对大家有所帮助。

相关内容

最新更新