- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 Zendesk php class ,下面的函数用于删除附件。
/**
* Delete one or more attachments by token or id
* $params must include one of these:
* 'token' - the token given to you after the original upload
* 'id' - the id of the attachment
*
* @param array $params
*
* @throws MissingParametersException
* @throws ResponseException
* @throws \Exception
*
* @return bool
*/
public function delete(array $params) {
if(!$this->hasAnyKey($params, array('id', 'token'))) {
throw new MissingParametersException(__METHOD__, array('id', 'token'));
}
$endPoint = Http::prepare(($params['token'] ? 'uploads/'.$params['token'] : 'attachments/'.$params['id']).'.json');
$response = Http::send($this->client, $endPoint, null, 'DELETE');
if ($this->client->getDebug()->lastResponseCode != 200) {
throw new ResponseException(__METHOD__);
}
$this->client->setSideload(null);
return true;
}
根据评论,运行此功能时需要 token 或ID。
我试过用id
$attachment = $client->attachments()->delete(array('id'=>'1187146218','token'));
但是它一直抛出异常
PHP Notice: Undefined index: token in /home/adam/web/srv11/public_html/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Attachments.php on line 106
PHP Fatal error: Uncaught exception 'Zendesk\API\ResponseException' with message 'Response to Zendesk\API\Attachments::delete is not valid. Call $client->getDebug() for details' in /home/adam/web/srv11/public_html/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Attachments.php:109
Stack trace:
#0 /home/adam/web/srv11/public_html/functions/support-attachment-delete.php(15): Zendesk\API\Attachments->delete(Array)
#1 {main}
thrown in /home/adam/web/srv11/public_html/vendor/zendesk/zendesk_api_client_php/src/Zendesk/API/Attachments.php on line 109
非常感谢您的帮助
最佳答案
你写这个的方式
array('id'=>'1187146218','token')
实际上给出了这样一个数组:
array('id'=>'1187146218', 0 => 'token')
因此没有“ token ”索引。如果您只是更改为
,这应该可以工作$attachment = $client->attachments()->delete(array('id'=>'1187146218','token' => NULL));
关于PHP 通知 : Undefined index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30516416/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!