如何使用Trello API使用自定义字段创建卡

我将Web应用程序堆叠在一起,需要在其中创建带有自定义文本的卡片。我有文件trello.php,我在其中发布程序中的信息,例如姓名,电话号码,电子邮件和日期。数字,文本和日期来自自定义字段。我阅读了文档,但从未成功创建工作代码。

在文档中被提及:

// Custom Field Type - Text
{
  "value": { "text": "Hello,world!" }
}

因此,我尝试了几种发送此信息的方法,但没有成功:

$trello = new trello_api($key,$secret,$token);

$trello->request('POST','/1/cards',array('name' => $card_name,'idList' => $list_id,'labels' => 'red','*here is field ID*' => array( 'value' => array ( 'text' => 'test@test.tst'))));

unset($trello);

我正在使用此API:

<?php
      class trello_api {
        private $key;
        private $secret;
        private $token;

        public function __construct ($key,$token) {
          $this->key = $key;
          $this->secret = $secret;
          $this->token = $token;
        }

        public function request ($type,$request,$args = false) {
          if (!$args) {
            $args = array();
          } elseif (!is_array($args)) {
            $args = array($args);
          }

          if (strstr($request,'?')) {
            $url = 'https://api.trello.com' . $request . '&key=' . $this->key . '&token=' . $this->token;
          } else {
            $url = 'https://api.trello.com' . $request . '?key=' . $this->key . '&token=' . $this->token;
          }

          $c = curl_init();
          curl_setopt($c,CURLOPT_HEADER,0);
          curl_setopt($c,CURLOPT_VERBOSE,CURLOPT_RETURNTRANSFER,1);
          curl_setopt($c,CURLOPT_URL,$url);

          if (count($args)) curl_setopt($c,CURLOPT_POSTFIELDS,http_build_query($args));

          switch ($type) {
            case 'POST':
              curl_setopt($c,CURLOPT_POST,1);
              break;
            case 'GET':
              curl_setopt($c,CURLOPT_HTTPGET,1);
              break;
            default:
              curl_setopt($c,CURLOPT_CUSTOMREQUEST,$type);
          }

          $data = curl_exec($c);
          curl_close($c);


          return json_decode($data);


        }
      }
    ?> 
zhuangwei519 回答:如何使用Trello API使用自定义字段创建卡

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2730211.html

大家都在问