Difference between revisions of "Template:API HTTP Example Boilerplate"

From SmartBots Developers Docs
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<syntaxhighlight lang="lsl">
+
''(the example uses [[HTTP API/LSL Helper Functions|smartbotsAPI()]] helper function. Set your "apikey", "botname" and "secret" in that function)''
/**
+
Send SmartBots HTTP API command.
+
*/
+
smartbotsAPI(string command, list params) {
+
  // You need to adjust the vars below:
+
  string sbApiKey = "...";
+
  string sbBotName = "...";
+
  string sbBotAccessCode = "...";
+
 
+
  // Populate the query data
+
  params += [
+
    "action="  + command,
+
    "apikey=" + llEscapeURL(sbApiKey),
+
    "botname=" + llEscapeURL(sbBotName),
+
    "secret=" + llEscapeURL(sbBotAccessCode)
+
  ];
+
 
+
  string query = llDumpList2String(params, "&");
+
+
  llHTTPRequest("http://api.mysmartbots.com/api/bot.html",
+
    [HTTP_METHOD,"POST"], query);
+
}
+
 
+
/*
+
Usage example:
+
 
+
smartbotsAPI("im", [
+
  "slname", "Glaznah Gassner",
+
  "message", "Hello in-world!"
+
]);
+
*/
+
 
+
</syntaxhighlight>
+

Latest revision as of 19:18, 4 March 2019

(the example uses smartbotsAPI() helper function. Set your "apikey", "botname" and "secret" in that function)