Skip to content
Browse files

Merge remote-tracking branch 'akrabat/apiv1tester_event'

  • Loading branch information...
2 parents c7541d5 + f96c992 commit 8a0ec329447abeeaeb206c547ad759ac22bd1446 @lornajane lornajane committed
Showing with 122 additions and 5 deletions.
  1. +6 −1 doc/apiv1_tester/README
  2. +116 −4 doc/apiv1_tester/apiv1_tester.php
View
7 doc/apiv1_tester/README
@@ -7,4 +7,9 @@ available, just type:
$ php apiv1_test.php
-Edit the top of the file to set URL, username and password.
+Set these environment variables to control URL and credentials:
+
+ * JIAPIV1_URL
+ * JIAPIV1_USERNAME
+ * JIAPIV1_PASSWORD
+
View
120 doc/apiv1_tester/apiv1_tester.php
@@ -1,8 +1,8 @@
<?php
// Set these:
-define('URL', 'http://joindin.localhost/api/');
-define('USERNAME', 'imaadmin');
-define('PASSWORD', 'password');
+define('URL', getenv('JIAPIV1_URL') ? getenv('JIAPIV1_URL') : 'http://joindin.localhost/api/');
+define('USERNAME', getenv('JIAPIV1_USERNAME') ? getenv('JIAPIV1_USERNAME') : 'imaadmin');
+define('PASSWORD', getenv('JIAPIV1_PASSWORD') ? getenv('JIAPIV1_PASSWORD') : 'password');
// Some settings:
define('OUTPUT', 'xml'); // json or xml
@@ -16,7 +16,9 @@
// ===================================================================
function help()
{
- echo <<<EOT
+ $username = USERNAME;
+
+ echo <<<EOT
Joind.in API v1 simple tester
Usage:
@@ -35,7 +37,15 @@ function help()
* event getlist upcoming
* event getlist hot
* event gettalkcomments {event_id}
+ * event getcomments {event_id}
* event addcomment {event_id} {comment}
+ * event deletecomment {event_id} {comment_id}
+ * event addtrack {event_id} {track_name} {track_desc}
+ * event updatetrack {event_id} {track_id} {track_name} {track_desc} {track_color}
+ * event deletetrack {event_id} {track_id}
+ * event addadmin {event_id} {username}
+ * event rmadmin {event_id} {username}
+ * event attend {event_id}
* talk getdetail {talk_id}
* talk getcomments {talk_id}
@@ -44,6 +54,10 @@ function help()
* comment isspam {commend_id} {talk_id} [{rtype=talk}]
+Current username: $username
+(Set environment variables JIAPIV1_USERNAME and JIAPIV1_PASSWORD to change)
+
+
EOT;
}
@@ -133,6 +147,11 @@ function event($command, $args)
$result = call_api('event', 'gettalkcomments', array("event_id"=>$eventId));
break;
+ case 'getcomments':
+ $eventId = getarg($args, 0);
+ $result = call_api('event', 'getcomments', array("event_id"=>$eventId));
+ break;
+
case 'addcomment':
$eventId = getarg($args, 0);
$comment = getarg($args, 1);
@@ -146,6 +165,99 @@ function event($command, $args)
"event_id"=>$eventId, "comment"=>$comment));
break;
+ case 'deletecomment':
+ $eventId = getarg($args, 0);
+ $commentId = getarg($args, 1);
+
+ if (!$commentId) {
+ echo "ERROR: No comment id supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'deletecomment', array("eid"=>$eventId,
+ "cid"=>$commentId));
+ break;
+
+ case 'addtrack':
+ $eventId = getarg($args, 0);
+ $trackName = getarg($args, 1);
+ $trackDesc = getarg($args, 2);
+
+ if (!$trackDesc) {
+ echo "ERROR: No track desc supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'addtrack', array("event_id"=>$eventId,
+ 'track_name'=>$trackName, 'track_desc'=>$trackDesc));
+ break;
+
+ case 'updatetrack':
+ $eventId = getarg($args, 0);
+ $trackId = getarg($args, 1);
+ $trackName = getarg($args, 2);
+ $trackDesc = getarg($args, 3);
+ $trackColor = getarg($args, 4);
+
+ if (!$trackDesc) {
+ echo "ERROR: No track color supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'updatetrack', array("event_id"=>$eventId,
+ 'track_id'=>$trackId,'track_name'=>$trackName,
+ 'track_desc'=>$trackDesc, 'track_color'=>$trackColor));
+ break;
+
+ case 'deletetrack':
+ $eventId = getarg($args, 0);
+ $trackId = getarg($args, 1);
+
+ if (!$trackId) {
+ echo "ERROR: No track color supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'deletetrack', array("event_id"=>$eventId,
+ 'track_id'=>$trackId));
+ break;
+
+ case 'addadmin':
+ $eventId = getarg($args, 0);
+ $username = getarg($args, 1);
+
+ if (!$username) {
+ echo "ERROR: No username supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'addadmin', array("eid"=>$eventId,
+ 'username'=>$username));
+ break;
+
+ case 'rmadmin':
+ $eventId = getarg($args, 0);
+ $username = getarg($args, 1);
+
+ if (!$username) {
+ echo "ERROR: No username supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'rmadmin', array("eid"=>$eventId,
+ 'username'=>$username));
+ break;
+
+ case 'attend':
+ $eventId = getarg($args, 0);
+
+ if (!$eventId) {
+ echo "ERROR: No event id supplied\n";
+ exit(2);
+ }
+
+ $result = call_api('event', 'attend', array("eid"=>$eventId));
+ break;
default:
echo "ERROR: invalid command\n";

0 comments on commit 8a0ec32

Please sign in to comment.
Something went wrong with that request. Please try again.