-- Here is an PHP example for calling Lua webservice
-- Author: Luke
-- Date: 2010-03-10
Code: Select all
<?php
$strUrl = "http://127.0.0.1:5466/admin_webservice.html";
$strUrlParam = "?admin=demo&pass=demo123&cmd=";
$strLuaScript = <<<EOT
local strDomain = "mydomain"
local strUsername = "myuser"
local strNewPass = "12345"
local tableUser = c_GetUser(strDomain,strUsername)
--change all the boolean values into integer values
for k,v in pairs(tableUser) do
if type(v) == "boolean" then
if v == true then
tableUser[k] = 1
else
tableUser[k] = 0
end
end
end
tableUser.password = strNewPass
AddUser(strDomain,tableUser)
EOT;
$strResult = file_get_contents($strUrl.$strUrlParam.rawurlencode($strLuaScript));
print($strResult);
?>