Created
February 7, 2012 03:35
-
-
Save use/1756989 to your computer and use it in GitHub Desktop.
Post a card to Trello using the API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$trello_key = '123412341234123412341234'; | |
$trello_api_endpoint = 'https://api.trello.com/1'; | |
$trello_list_id = '1234123412341234123412341234'; | |
$trello_member_token = '12341234123412341234123412341234'; // Guard this well | |
$ch = curl_init("$trello_api_endpoint/cards"); | |
curl_setopt_array($ch, array( | |
CURLOPT_SSL_VERIFYPEER => false, // Probably won't work otherwise | |
CURLOPT_RETURNTRANSFER => true, // So we can get the URL of the newly-created card | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => http_build_query(array( // if you use an array without being wrapped in http_build_query, the Trello API server won't recognize your POST variables | |
'key' => $trello_key, | |
'token' => $trello_member_token, | |
'idList' => $trello_list_id, | |
'name' => "Cool Name for a Card", | |
'desc' => "Try using some\n\n*markdown* in your description" | |
)), | |
)); | |
$result = curl_exec($ch); | |
$trello_card = json_decode($result); | |
$trello_card_url = $trello_card->url; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment