PHP SDK: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 7: | Line 7: | ||
==Examples== | ==Examples== | ||
<syntaxhighlight lang="lua">[php] | <syntaxhighlight lang="lua">[php] | ||
$retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getThisResource" ) // $retn is an array containing the values the function returned | include ( "mta.php" ); | ||
$retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getThisResource" ); // $retn is an array containing the values the function returned | |||
$resource = $retn[0]; // the first returned value is the resource | $resource = $retn[0]; // the first returned value is the resource | ||
$retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getResourceName", $resource ) | $retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getResourceName", $resource ); | ||
$resourceName = $retn[0] // contains the name of the resource 'echobot' | $resourceName = $retn[0]; // contains the name of the resource 'echobot' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Download== | ==Download== | ||
*[http://misc.opencoding.net/mta/mtaphpsdk_0.1.zip Download Version 0.1] | *[http://misc.opencoding.net/mta/mtaphpsdk_0.1.zip Download Version 0.1] |
Revision as of 19:27, 26 June 2007
You can access the MTA Web Interface from almost any programming language that can request web pages using HTTP POST and encode and decode JSON.
PHP can do this very easily! This SDK provides one function "callFunction" that will allow you to call any exported script functions on any server that you have access to.
The download below includes two example pages - one that shows a simple scoreboard, the other that shows the automatic handling of element and resource objects.
Examples
[php] include ( "mta.php" ); $retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getThisResource" ); // $retn is an array containing the values the function returned $resource = $retn[0]; // the first returned value is the resource $retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getResourceName", $resource ); $resourceName = $retn[0]; // contains the name of the resource 'echobot'