From 5e90a695d9e7dc744eec1b2f021f946d34165723 Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 21:55:38 +0100 Subject: [PATCH 1/7] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdfdf21..f4c1057 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ SUMMARY ------- -This is a thin PHP library for integration with the Challonge API. Uses cURL for http request and SimpleXML for the response handling. Just appends API Key +This is a thin PHP library for integration with the Challonge API. Uses cURL for http request and SimpleXML for the response handling. Just appends API Key. +Master by craigjackson forked from wshatch's master. +This fork updates to api v1 and adds "attachments" api requests. +by Mano82 EXAMPLE ------- From a00043b941d9a70d2ab76255f2de469c5ee3351e Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 21:56:36 +0100 Subject: [PATCH 2/7] Update and rename src/Challonge to src/Challonge/Attachment.php --- src/Challonge/Attachment.php | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Challonge/Attachment.php diff --git a/src/Challonge/Attachment.php b/src/Challonge/Attachment.php new file mode 100644 index 0000000..3cd8157 --- /dev/null +++ b/src/Challonge/Attachment.php @@ -0,0 +1,41 @@ +ids = self::PREFIX."/".$tournament_id."/matches/".$match_id."/attachments"; + } + + public function reqIndex() + { + return $this->request("/{$this->ids}"); + } + + public function reqCreate() + { + return $this->request("/{$this->ids}",'post'); + } + + public function reqShow($id) + { + return $this->request("/{$this->ids}/$id"); + } + + public function reqUpdate($id) + { + return $this->request("/{$this->ids}/$id",'put'); + } + + public function reqDestroy($id) + { + return $this->request("/{$this->ids}/$id",'delete'); + } +} + From 87a4df86cd3d2de79180b7f15d6059fadb9eb4f7 Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 21:59:15 +0100 Subject: [PATCH 3/7] Update Match.php modified path and added methods for api v1 --- src/Challonge/Match.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Challonge/Match.php b/src/Challonge/Match.php index d01f706..d609710 100644 --- a/src/Challonge/Match.php +++ b/src/Challonge/Match.php @@ -6,10 +6,11 @@ class ChallongeMatch extends ChallongeAPI { protected $tournament_id; + const PREFIX = "tournaments"; public function __construct($tournament_id) { - $this->tournament_id = $tournament_id; + $this->tournament_id = self::PREFIX."/".$tournament_id; } public function reqIndex() From b6a44c597c07113c82c0b001fe9829657f3df138 Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 22:00:07 +0100 Subject: [PATCH 4/7] Update Participant.php modified paths and added methods for updated api v1 --- src/Challonge/Participant.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Challonge/Participant.php b/src/Challonge/Participant.php index fa024ac..7a27070 100644 --- a/src/Challonge/Participant.php +++ b/src/Challonge/Participant.php @@ -6,10 +6,11 @@ class ChallongeParticipant extends ChallongeAPI { protected $tournament_id; + const PREFIX = "tournaments"; public function __construct($tournament_id) { - $this->tournament_id = $tournament_id; + $this->tournament_id = self::PREFIX."/".$tournament_id; } public function reqIndex() @@ -21,6 +22,11 @@ public function reqCreate() { return $this->request("/{$this->tournament_id}/participants", 'post'); } + + public function reqBulkAdd() + { + return $this->request("/{$this->tournament_id}/participants/bulk_add", 'post'); + } public function reqShow($id) { @@ -31,6 +37,11 @@ public function reqUpdate($id) { return $this->request("/{$this->tournament_id}/participants/$id", 'put'); } + + public function reqCheckIn($id) + { + return $this->request("/{$this->tournament_id}/participants/$id/check_in", 'post'); + } public function reqDestroy($id) { @@ -43,3 +54,5 @@ public function reqRandomize() } } + + From 57547c142d6884ec9afd3ac707646074f3e78b3f Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 22:00:55 +0100 Subject: [PATCH 5/7] Update Tournament.php modified paths and added methods for updated api v1 --- src/Challonge/Tournament.php | 37 ++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Challonge/Tournament.php b/src/Challonge/Tournament.php index d09cb03..b46dbda 100644 --- a/src/Challonge/Tournament.php +++ b/src/Challonge/Tournament.php @@ -5,44 +5,61 @@ */ class ChallongeTournament extends ChallongeAPI { - public function reqIndex() + const PREFIX = "tournaments"; + + public function reqIndex() { - return $this->request(); + return $this->request(self::PREFIX); } public function reqCreate() { - return $this->request('', 'post'); + return $this->request(self::PREFIX, 'post'); } public function reqShow($id) { - return $this->request("/$id"); + return $this->request(self::PREFIX."/$id"); } public function reqUpdate($id) { - return $this->request("/$id", 'put'); + return $this->request(self::PREFIX."/$id", 'put'); } public function reqDestroy($id) { - return $this->request("/$id", 'delete'); + return $this->request(self::PREFIX."/$id", 'delete'); } - public function reqPublish($id) + /*public function reqPublish($id) { return $this->request("/publish/$id", 'post'); - } + }*/ public function reqStart($id) { - return $this->request("/start/$id", 'post'); + return $this->request(self::PREFIX."/$id/start", 'post'); } public function reqReset($id) { - return $this->request("/reset/$id", 'post'); + return $this->request(self::PREFIX."/$id/reset", 'post'); + } + + public function reqFinalize($id) + { + return $this->request(self::PREFIX."/$id/finalize", 'post'); + } + + public function reqProcessCheckIns($id) + { + return $this->request(self::PREFIX."/$id/process_check_ins", 'post'); + } + + public function reqAbortCheckIn($id) + { + return $this->request(self::PREFIX."/$id/abort_check_in", 'post'); } } From e7561e1edeb5742bfaf0b0973587e5a63bff6b50 Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 22:01:57 +0100 Subject: [PATCH 6/7] Update API.php fixed api url for API v1 update --- src/Challonge/API.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Challonge/API.php b/src/Challonge/API.php index 2deaf79..eaad266 100644 --- a/src/Challonge/API.php +++ b/src/Challonge/API.php @@ -11,7 +11,7 @@ class ChallongeAPI { - const API_URL = 'https://challonge.com/api/tournaments'; + const API_URL = 'https://api.challonge.com/v1/'; const API_EXT = '.xml'; static public $api_key; protected $params = array(); @@ -43,7 +43,7 @@ public function request($url_append = '', $method = 'get', $params = array()) { case 'get': curl_setopt($ch, CURLOPT_URL, $this->prepareURL($url_append, $params)); - break; + break; case 'post': curl_setopt($ch, CURLOPT_URL, $this->prepareURL($url_append)); curl_setopt($ch, CURLOPT_POST, true); @@ -64,6 +64,7 @@ public function request($url_append = '', $method = 'get', $params = array()) default: return false; } + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); if ($response === false) { @@ -75,7 +76,7 @@ public function request($url_append = '', $method = 'get', $params = array()) public function prepareURL($url_append, $params = array()) { - return self::API_URL . $url_append . self::API_EXT . '?' . http_build_query(array_merge($params, array('api_key' => self::$api_key)), '', '&'); + return self::API_URL . $url_append . self::API_EXT . '?' . http_build_query(array_merge($params, array('api_key' => self::$api_key)), '', '&'); } protected function handleResponse($response) From 8e5c5d6fb1b7cc152a9158b0e86810e9bf8682df Mon Sep 17 00:00:00 2001 From: mano82 Date: Fri, 27 Feb 2015 22:05:52 +0100 Subject: [PATCH 7/7] File added Added attachment file missing from original master and API --- src/Challonge/Attachment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Challonge/Attachment.php b/src/Challonge/Attachment.php index 3cd8157..e30723f 100644 --- a/src/Challonge/Attachment.php +++ b/src/Challonge/Attachment.php @@ -1,6 +1,6 @@