Created
August 1, 2012 11:09
-
-
Save kiafaldorius/3225852 to your computer and use it in GitHub Desktop.
Kanbanpad PHP Example
This file contains 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
<?php | |
# Example create project on kanbanpad api using json | |
# Runs on PHP 5.3 with curl and json extension | |
# Note the https, the s is required. | |
$curl = curl_init("https://www.kanbanpad.com/api/v1/projects.json"); | |
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($curl, CURLOPT_USERPWD, '[email protected]:e754f5335230f9bad9b5dc90ceb5ab0c76a06604'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, array('name' => 'API create')); | |
$result_str = curl_exec($curl); | |
$result = json_decode($result_str, true); | |
var_dump($result); | |
curl_close($curl); | |
/* When run it outputs something like: | |
array(9) { ["created_at"]=> string(20) "2012-08-01T11:09:20Z" ["email"]=> string(27) "[email protected]" ["id"]=> string(24) "50190e605bc84c000a07a47e" ["name"]=> string(10) "API create" ["organization_id"]=> NULL ["privacy"]=> int(0) ["slug"]=> string(20) "52651ede63d04c12c429" ["updated_at"]=> string(20) "2012-08-01T11:09:20Z" ["wip_limit"]=> int(10) } | |
*/ |
This file contains 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
<?php | |
# Example task create on kanbanpad api using json | |
# Runs on PHP 5.3 with curl and json extension | |
$curl = curl_init("https://www.kanbanpad.com/api/v1/projects/52651ede63d04c12c429/tasks.json"); | |
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($curl, CURLOPT_USERPWD, '[email protected]:e754f5335230f9bad9b5dc90ceb5ab0c76a06604'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, array('task[title]' => 'This is my task', 'task[note]' => 'Hey, it works!')); | |
$result_str = curl_exec($curl); | |
$result = json_decode($result_str, true); | |
var_dump($result); | |
curl_close($curl); | |
/* When it runs, it outputs something like: | |
array(14) { ["assigned_to"]=> array(0) { } ["backlog"]=> bool(false) ["comments_total"]=> int(0) ["created_at"]=> string(20) "2012-08-01T11:17:00Z" ["finished"]=> bool(false) ["id"]=> string(24) "5019102c5bc84c000a07b9c6" ["note"]=> string(14) "Hey, it works!" ["project_slug"]=> string(20) "52651ede63d04c12c429" ["step_id"]=> string(24) "50190e605bc84c000a07a47f" ["task_id"]=> int(3) ["title"]=> string(15) "This is my task" ["updated_at"]=> string(20) "2012-08-01T11:17:00Z" ["urgent"]=> bool(false) ["wip"]=> bool(false) } | |
*/ |
This file contains 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
<?php | |
# Example task update on kanbanpad api using json | |
# Runs on PHP 5.3 with curl and json extension | |
$curl = curl_init("https://www.kanbanpad.com/api/v1/projects/52651ede63d04c12c429/tasks/5019102c5bc84c000a07b9c6.json"); | |
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($curl, CURLOPT_USERPWD, '[email protected]:e754f5335230f9bad9b5dc90ceb5ab0c76a06604'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POST, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, array('task[title]' => 'This is my task (updated)', '_method' => 'PUT')); | |
$result_str = curl_exec($curl); | |
$result = json_decode($result_str, true); | |
var_dump($result); | |
curl_close($curl); | |
/* When run, it outputs something like: | |
array(14) { ["assigned_to"]=> array(0) { } ["backlog"]=> bool(false) ["comments_total"]=> int(0) ["created_at"]=> string(20) "2012-08-01T11:17:00Z" ["finished"]=> bool(false) ["id"]=> string(24) "5019102c5bc84c000a07b9c6" ["note"]=> string(14) "Hey, it works!" ["project_slug"]=> string(20) "52651ede63d04c12c429" ["step_id"]=> string(24) "50190e605bc84c000a07a47f" ["task_id"]=> int(3) ["title"]=> string(25) "This is my task (updated)" ["updated_at"]=> string(20) "2012-08-01T11:20:13Z" ["urgent"]=> bool(false) ["wip"]=> bool(false) } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment