我是twitter API的新手,我正在尝试使用php创建一个应用程序。我创建了以下代码:
<?php
session_start();
require_once("src/TwitterOAuth.php");
$apikey="mykey";
$apisecret="mysecret";
$accesstoken="mytoken";
$accesssecret="secrettoken";
$connection = new TwitterOAuth($apikey, $apisecret, $accesstoken, $accesssecret);
$tweets =
$connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2");
print_r($tweets);
?>我得到了以下错误:
Parse error: syntax error, unexpected '[' in /home/sites/crimsonroot.com/public_html/twitter/twitteroauth-master/src/TwitterOAuth.php on line 334 我从github下载了twitter,并将其上传到我的服务器上,因此我知道来自twitter的php文档是正确的。
有什么不对的吗?
发布于 2015-07-22 22:45:01
替换
if (in_array($method, ['GET', 'PUT', 'DELETE']) && !empty($postfields)) { $options[CURLOPT_URL] .= '?' . Util::buildHttpQuery($postfields); }使用
if (in_array($method, array('GET', 'PUT', 'DELETE')) && !empty($postfields)) { $options[CURLOPT_URL] .= '?' . Util::buildHttpQuery($postfields); }--我不知道他为什么要用[]这绝对不是php语法
--为了确定我再次访问了php手册,我错了,这段代码显示为一种创建数组的新方法,只适用于php 5.4+。因此,升级php或编辑不合适的代码。
https://stackoverflow.com/questions/31574799
复制相似问题