T_STRING error at Curl [closed]

≡放荡痞女 提交于 2019-12-13 23:51:54

问题


When I'll upload my .php I get these error:

Parse error: syntax error, unexpected T_STRING in /users/allybong/www/twitteroauth/twitteroauth/twitteroauth.php on line 201

The script of line 197 - 231:

  function http($url, $method, $postfields = NULL) {
$this->http_info = array();
$ci = curl_init()
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent)
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout)
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout)
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE)
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'))
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer)
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'))
curl_setopt($ci, CURLOPT_HEADER, FALSE)

switch ($method) {
  case 'POST':
    curl_setopt($ci, CURLOPT_POST, TRUE);
    if (!empty($postfields)) {
      curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
    }
    break;
  case 'DELETE':
    curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
    if (!empty($postfields)) {
      $url = "{$url}?{$postfields}";
    }
}

curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close ($ci);
return $response;

}

These is a script for a Twitter "BongBot". I get it from https://github.com/lizconlan/bongbot .


回答1:


There are a lot of missing semicolons on the lines you pasted. That is probably the reason it gives you a T_STRING error.




回答2:


After and including the following line, none of your lines end with a semicolon:

$ci = curl_init()

Try adding one to the following lines and it should resolve your issue:

$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
curl_setopt($ci, CURLOPT_HEADER, FALSE);


来源:https://stackoverflow.com/questions/14219070/t-string-error-at-curl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!