简体   繁体   English

TwitterOAuth.php将不会运行“使用”

[英]TwitterOAuth.php will not run 'use'

Error is: 错误是:

Parse error: syntax error, unexpected 'use' (T_USE) in /Applications/MAMP/htdocs/wp-content/plugins/plugin-name/includes/display-functions.php on line 9 解析错误:语法错误,/ Applications / MAMP / htdocs / wp-content / plugins / plugin-name / includes / display-functions.php中第9行中的意外“使用”(T_USE)

require_once "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;    //<--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));

Any help would be greatly appreciated. 任何帮助将不胜感激。

I have just stumbled on this. 我刚刚偶然发现。

I haven't been able to figure out why it wasn't working but managed a simple workaround. 我一直无法弄清为什么它不起作用,但却设法解决了一个简单的解决方法。

This is the working code: 这是工作代码:

require_once "twitteroauth/autoload.php";
//use Abraham\TwitterOAuth\TwitterOAuth;    //<--this is line 9 where the error occurs

$consumerkey = '***************';
$consumersecret = '*********************************************';
$accesstoken = '*********************************************';
$accesstokensecret = '******************************';

$connection = new Abraham\TwitterOAuth\TwitterOAuth($consumerkey, $consumersecret ,$accesstoken, $accesstokensecret);

Hope it might be of help to anyone. 希望对任何人都有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM