我正在尝试将发帖请求发送到我的Trello委员会。我现在尝试了许多小时,但每次都无法正常工作。我已经检查了很多遍代码,但没有得到解决。
我正在使用该API:
<?php
class trello_api
{
private $key;
private $token;
public function __construct($key,$token)
{
$this->key = $key;
$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/1/' . $request . '&key=' . $this->key . '&token=' . $this->token;
} else {
$url = 'https://api.trello.com/1/' . $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);
echo curl_error($c);
curl_close($c);
return json_decode($data);
}
}
这是我的Post请求的PHP代码:
$trello->request('POST','cards',array('name' => $card_name,'idList' => $list_id));
但是没有将卡片添加到列表中。 :/ 有人可以帮我解决我的问题吗?