php unexpected t_string,解析錯誤:語法錯誤,意外的“}”,期望T_STRING客戶端。php在第137行...

Here is the code, I cannot find any unenclosed single or double quotes - but when executed it returns

這里是代碼,我找不到任何未封裝的單引號或雙引號——但是當執行時它返回。

Parse error: syntax error, unexpected '}', expecting T_STRING client.php on line 137

解析錯誤:語法錯誤,意外的“}”,期望T_STRING客戶端。php在第137行

:

:

/**

* An API client for Dropbox

*/

class DropboxClient

{

protected $Session = null;

/**

* Common API URL

* @var

*/

protected $dropboxAPIURL = "https://api.dropbox.com/1";

/**

* Content-related API URL

* @var

*/

protected $dropboxContentAPIURL = "https://api-content.dropbox.com/1";

/**

* Constructor

*

* Initialize the client wit a valid session

*

* @param object $session

* @return void

*/

function __construct( DropboxSession $session) {

$this->Session = $session;

$this->accessType = $this->Session->getAccessType();

}

/**

* Retrieve information from the user's account

*

* @return string

*/

public function accountInfo() {

$response = $this->Session->fetch("GET", $this->dropboxAPIURL, "/account/info");

return $response["body"];

}

/**

* Fetch metadata for a file or folder

*

* The path is relative to a root (ex //) that can be 'sandbox' or 'dropbox'

*

* @param string $path The path of the resource to fetch

* @param boolean $list Whether to list all contained files (applies only to folders)

* @param int $fileLimit Max items returned with the listing mode

* @param string $hash Hash value for a previous call

* @param string $revision Specific revision for the object

* @param bool $includeDeleted Whether to include deleted files and folders

* @return string

*/

public function metadata($path, $list = true, $fileLimit = 10000, $hash = null, $revision = null, $includeDeleted = false) {

// Prepare argument list

$args = array(

"file_limit" => $fileLimit,

"hash" => $hash,

"list" => (int) $list,

"include_deleted" => (int) $includeDeleted,

"rev" => $revision

);

// Prepend the right access string to the desired path

if ("dropbox" == $this->accessType) {

$path = "dropbox" . $path;

}

else {

$path = "sandbox" . $path;

}

// Execute

$response = $this->Session->fetch("GET", $this->dropboxAPIURL, "/metadata/" . $path, $args);

return $response["body"];

}

/**

* Downloads a file from the user's Dropbox

*

* The path is relative to a root (ex //) that can be 'sandbox' or 'dropbox'

*

* @param string $path The path of the resource to fetch

* @param string $outFile The download path for the file

* @param string $revision Specific revision for the object

* @return array

*/

public function getFile($path, $outFile = null, $revision = null) {

$args = array();

if (!empty($revision)) {

$args["rev"] = $revision;

}

// Prepend the right access string to the desired path

if ("dropbox" == $this->accessType) {

$path = "dropbox" . $path;

}

else {

$path = "sandbox" . $path;

}

// Get the raw response body

$response = $this->Session->fetch("GET", $this->dropboxContentAPIURL, "/files/" . $path, $args, true);

if ($outFile != null) {

if (file_put_contents($outFile, $response["body"]) === false) {

throw new Exception("Unable to write file '$outfile'");

}

}

return array(

"name" => ($outFile) ? $outFile : basename($path),

"mime" => $response["headers"]["content-type"],

"meta" => json_decode($response["headers"]["x-dropbox-metadata"]),

"data" => $response["body"]

);

}

/**

* Upload a file to the user's Dropbox

*

* The path is relative to a root (ex //) that can be 'sandbox' or 'dropbox'

*

* @param string $file The full path of the file to upload

* @param string $path The destination path (default = root)

* @param string $name Specifies a different name for the uploaded file

* @param boolean $overwrite Overwrite any existing file

* @return array

*/

public function putFile($file, $path = "/", $name = null, $overwrite = true) {

// Check for file existence before

if (!file_exists($file)) {

throw new Exception("Local file '" . $file . "' does not exist");\

}

// Dropbox has a 150MB limit upload for the API

if (filesize($file) > 157286400) {

throw new Exception("File exceeds 150MB upload limit");

}

$args = array(

"overwrite" => (int) $overwrite,

"inputfile" => $file

);

// Prepend the right access string to the desired path

if ("dropbox" == $this->accessType) {

$path = "dropbox" . $path;

}

else {

$path = "sandbox" . $path;

}

// Determine the full path

if (!empty($name)) {

$path = dirname($path) . "/" . $name;

}

else {

$path .= basename($file);

}

// Get the raw response body

$response = $this->Session->fetch("PUT", $this->dropboxContentAPIURL, "/files_put/" . $path, $args);

return $response["body"];

}

}

I cannot find any part of the code that could be causing the error on line 137 or above?

我找不到任何可能導致137行或以上錯誤的代碼。

3 个解决方案

#1

2

You have a backslash in the code on line 136:

在第136行的代碼中有一個反斜杠:

throw new Exception("Local file '" . $file . "' does not exist");\

^

#2

1

Here, you have an unnecessary backslash,

這里有一個不必要的反斜杠,

throw new Exception("Local file '" . $file . "' does not exist");\

Note: Please use an IDE for detect such trivial errors.

注意:請使用IDE來檢測這些小錯誤。

#3

0

Is there meant to be a backslash on the end of this line?

在這條線的末端有反斜杠嗎?

Exception("Local file '" . $file . "' does not exist");\

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值