[Hw4mdl-svn] SF.net SVN: hw4mdl: [46] trunk/moodle/mod/liveclassroom/api.php
Brought to you by:
jhlinder,
trollinger
From: <sh...@us...> - 2006-08-25 10:37:50
|
Revision: 46 Author: shazan Date: 2006-08-25 03:37:42 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/hw4mdl/?rev=46&view=rev Log Message: ----------- new functions added to parse the http response and to get the roomId from the server Modified Paths: -------------- trunk/moodle/mod/liveclassroom/api.php Modified: trunk/moodle/mod/liveclassroom/api.php =================================================================== --- trunk/moodle/mod/liveclassroom/api.php 2006-08-25 09:15:56 UTC (rev 45) +++ trunk/moodle/mod/liveclassroom/api.php 2006-08-25 10:37:42 UTC (rev 46) @@ -52,6 +52,7 @@ $LIVECLASSROOM_API_FUNCTION_DELETE_ROLE = 'function=deleteRole'; $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST = 'function=listClass'; +$LIVECLASSROOM_API_RECORD_SEPERATOR = "=END RECORD"; /** * Creates a CURL session with the Live Classroom server. Upon success, it @@ -451,13 +452,14 @@ function liveclassroom_api_room_exist($roomname) { global $CFG; + global $LIVECLASSROOM_API_RECORD_SEPERATOR; global $LIVECLASSROOM_API_ADMIN, $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname"); - print $data; + //print $data; preg_match("(\d*)", $data, $matches); $respcode = $matches[0]; @@ -466,16 +468,20 @@ } // print($data); $tok = split("100 OK",$data); - $tok1 = split("=END RECORD",$tok[1]); - /* while($tok) { - echo $tok."<br>"; - $tok = split("100 OK"); - $number++; + //print $tok[1]; + $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]); + // print $tok1[1]; + //print (liveclassroom_parse_line($tok1[1],"class_id=")); + + /* + + for($i=0;$i<sizeof($tok1);$i++) { + //print $tok1[$i]."<br>" ; + print (liveclassroom_parse_line($tok1[$i],"class_id="))."<br>"; } - */ - // echo "number".$number."br"; -// print($tok1); -// echo "number".sizeof($tok1); +*/ +// print (liveclassroom_api_get_roomid($roomname))."<br>"; + if(sizeof($tok1)>1){ return true; @@ -523,5 +529,57 @@ } +/** +* Parses the HTTP response body +* +* @param response +* @throws +*/ +function liveclassroom_parse_response($response) { + return true; +} + +/** +* +* return a string delimited by the pattern and the end of line +*/ +function liveclassroom_parse_line($line,$pattern) { + + $response = split($pattern,$line); + //print $response; + return $response[1]; + +} + +/** +* @params $roomname +* return the room_id from the server +*/ +function liveclassroom_api_get_roomid($roomname) { + global $CFG; + global $LIVECLASSROOM_API_RECORD_SEPERATOR; + global $LIVECLASSROOM_API_ADMIN, + $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname"); + + //print $data; + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + // print($data); + $tok = split("100 OK",$data); + //print $tok[1]; + $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]); + // print $tok1[1]; + $result = liveclassroom_parse_line($tok1[0],"class_id="); + // print $result; + return $result; +} + + ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |