2012-08-27 2 views
1

내 웹 응용 프로그램에서 특정 이벤트가 발생하면 Trello API를 사용하여 새 카드를 만듭니다. Curl을 사용하여 요청을하고 싶습니다. 이것은 내 코드입니다.Trello Api : 서버에서 PHP 응답이 없습니다.

$url = "https://api.trello.com/1/cards?key=".$key."&token=".$token."&name=".$name."&idList=".$idList; 

# init curl 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // make sure we see the sended header afterwards 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 

# dont care about ssl 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

# download and close 
$output = curl_exec($ch); 
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT); 
$error = curl_error($ch); 
curl_close($ch); 

위도 나는 동일한 URL을 피들러와 함께 사용하려고했습니다. 그러나이 코드를 사용하면 "서버에서 빈 회신"오류가 다시 나타납니다. 아무도 내가 뭘 잘못하고있어?

답변

2

URL에 인수를 넣는 대신 CURLOPT_POSTFIELDS에 넣으십시오.

은 나를 위해 일한 :

$url = "https://api.trello.com/1/cards"; 
$fields = "key=$key&token=$token&name=$name&idList=$idList"; 

# init curl 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // make sure we see the sended header afterwards 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 

# dont care about ssl 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

# download and close 
$output = curl_exec($ch); 
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT); 
$error = curl_error($ch); 
curl_close($ch); 
+0

도 여기에 작동합니다. 이 대답을 받아 들여야합니다. – Julian

관련 문제