我正在使用一个Webhook来启动一系列利用Podio PHP API的PHP脚本。我尝试使用几种不同的API调用,但无法对其进行梳理。这是我正在使用的测试文件,因此执行该操作的实际逻辑没有多大意义。当我运行下面的代码时,我得到了错误。
PHP Fatal error: Uncaught PodioBadRequestError: "Invalid value "status" (string): Not a valid option"
Request URL: http://api.podio.com/item/<removed>/value/<removed>
Stack Trace:
/data/www/default/contracts/lib/podio-php-master/lib/Podio.php(357):
Podio::request('PUT', '/item/<removed>...', Array)
/data/www/default/contracts/lib/podio-php-master/models/PodioItemField.php(55): Podio::put('/item/<removed>...', Array)
/data/www/default/contracts/test-category.php(25):
PodioItemField::update(<removed>, <removed>, Array, Array)
{main}
thrown in /data/www/default/contracts/lib/podio-php-master/lib/Podio.php on line 291`
这是我的代码:
//dummy item_id
$item_id = 123456789;
//dummy field_id
$field_id = 987654321;
//Get the category field value
$item = PodioItem::get_field_value($item_id, $field_id);
//Create a variable with the text of the selected category option for validation
$button_value = $item[0]['value']['text'];
//Print the text of the selected option
print $button_value;
//Now that I have validated the current selection I want to change it
//These are the names of the attributes for my category
$my_attributes = array("status", "text", "id", "color");
//These are the values I want to update them to
$my_options = array("active","Generated",21,"DCEBD8");
//This should update the record in podio with the new values
PodioItemField::update($item_id, $field_id, $my_attributes, $my_options);
我查看了文档中的所有示例,但感觉好像缺少了一些简单的东西。有人可以告诉我我做错了什么吗?我试图对代码进行注释,以使我清楚希望在每一行上进行的编程,但是如果需要的话,我绝对可以澄清更多。
答案 0 :(得分:0)
您通过错误的方法传递属性。要更新类别字段,您只需在数组中传递要更改的选项的id
。因此$my_attributes
数组必须像
$my_attributes = array(21);//id of the category option
$my_options
数组应该这样,
$my_options = array('silent' => true, 'hook' => false);
这应该使用新值更新Podio中的项目,
PodioItemField::update($item_id, $field_id, $my_attributes, $my_options);