Difference between revisions of "Nexus Pager System/API"

From Nexus
Jump to: navigation, search
(Created page with "← Nexus Pager System {|align=right |__TOC__ |} = '''<span style="color:#4D5A93">API Documentation</span>''' = :The API Documentation is only relevant ...")
 
 
Line 33: Line 33:
 
#Paste that description into the prim where you have the API Script.
 
#Paste that description into the prim where you have the API Script.
 
#Create a new script and paste the following.
 
#Create a new script and paste the following.
<pre>integer TRANSMIT_PAGER      = 21001;
+
<pre>
integer TRANSMIT_SPEAKER    = 21002;
+
integer TRANSMIT_PAGER      = 21001; // The Number to pass into Link Message to tell the API script to send the message only to pagers.
integer TRANSMIT_ALL        = 21003;
+
integer TRANSMIT_SPEAKER    = 21002; // The Number to pass into Link Message to tell the API script to send the message only to speakers.
 +
integer TRANSMIT_ALL        = 21003; // The Number to pass into Link Message to tell the API script to send the message to everything.
  
 
string JSON;
 
string JSON;
 +
string channel = "CHANGE ME!"; //Change the name of this channel to something you have in your own network.
 +
string message = "Hello World!";
  
 
default {
 
default {
 
     touch_start(integer total_number) {
 
     touch_start(integer total_number) {
 
         if(llDetectedKey(0) == llGetOwner()) {
 
         if(llDetectedKey(0) == llGetOwner()) {
             JSON = llJsonSetValue(JSON,["channel"],"CHANGE ME"); //Change the name of this channel to something you have in your own network.
+
             JSON = llJsonSetValue(JSON,["channel"],channel);
             JSON = llJsonSetValue(JSON,["message"],"Hello World!");
+
             JSON = llJsonSetValue(JSON,["message"],message);
             llMessageLinked(LINK_THIS,TRANSMIT_PAGER,JSON,NULL_KEY);
+
             llMessageLinked(LINK_SET,TRANSMIT_PAGER,JSON,NULL_KEY);
 
         }
 
         }
 
     }
 
     }
Line 57: Line 60:
 
= '''<span style="color:#4D5A93">Transmitting Messages</span>''' =
 
= '''<span style="color:#4D5A93">Transmitting Messages</span>''' =
 
:One of the major functions that this API will allow you to do is to transmit messages to other users who have pagers or speakers.
 
:One of the major functions that this API will allow you to do is to transmit messages to other users who have pagers or speakers.
 
=== Information required for API call ===
 
* Channel
 
* Message
 
  
 
:You can find the channel by going to your channels in your computer terminal and selecting ''Channels'' Then ''List''.
 
:You can find the channel by going to your channels in your computer terminal and selecting ''Channels'' Then ''List''.
Line 67: Line 66:
 
:Sending a transmission is very simple once you have the hang of it.
 
:Sending a transmission is very simple once you have the hang of it.
  
=== Example Responses ===
+
=== Helpful Variables ===
:When you acquired an error because you did not supply an error, this is the response.
+
: There are some variables that are required to tell the API Script what you are trying to do.
:'''All errors will show up as the "Error" Key in the JSON value.'''
+
: The Numbers that you pass through the llLinkMessage() Function are the action that is sent to the API Script.
<pre>{
+
: '''Variable List'''
    "error" : "Please supply the name of the channel you would like to send a message on."
+
* TRANSMIT_PAGER = 21001 This action tells the API Script that you want to transmit a message to other pagers on a certain channel.
}</pre>
+
* TRANSMIT_SPEAKER = 21002 This will tell the API Script to only send a message to the speakers.
 +
* TRANSMIT_ALL = 21003 This will send messages to all the devices on that channel.
  
:Send that message and have it be a success? Here is the response.
+
:Did you send a message and have it be a success? Here is the response.
 
<pre>{
 
<pre>{
 
     "success" : "Message has been successfully sent!"
 
     "success" : "Message has been successfully sent!"
 
}</pre>
 
}</pre>

Latest revision as of 22:45, 19 May 2015

← Nexus Pager System

API Documentation

The API Documentation is only relevant to version number 3.0.0. Anything older than that will not work on this page.
This API is a transmit only API. Until we find a way to effectively send messages to a user with the API, we will not be displaying our receive API.
To use this API, you must have some knowledge of Linden Script Language and Linked Messages
Want to know what an API is? Look here on Wikipedia.
To navigate this wiki better, please use the navigation on the right side of the screen.

API Features


  • Transmitting Messages
  • Receiving Messages

How to make an API Call


Before you are to start messing with this, you must have knowledge of how Linden Scripting Language works. If you can't script, then this guide will be worthless to you.
Currently, there is only one way to make an API call. You are required to use our helper script that is supplied in the box when purchased. You can also obtain this script at the vendor in world.
If you are going to use Linked Messages you must either get the script from our In World Store or from your Product Box.

Setting Everything Up


Time to start setting things up!
Follow these steps and you should have a perfect prim that will be able to send out messages to anything.
  1. Create a prim and add the API Script.
  2. Edit the Computer Terminal and copy the computer's description.
  3. Paste that description into the prim where you have the API Script.
  4. Create a new script and paste the following.
integer TRANSMIT_PAGER      = 21001; // The Number to pass into Link Message to tell the API script to send the message only to pagers.
integer TRANSMIT_SPEAKER    = 21002; // The Number to pass into Link Message to tell the API script to send the message only to speakers.
integer TRANSMIT_ALL        = 21003; // The Number to pass into Link Message to tell the API script to send the message to everything.

string JSON;
string channel = "CHANGE ME!"; //Change the name of this channel to something you have in your own network.
string message = "Hello World!";

default {
    touch_start(integer total_number) {
        if(llDetectedKey(0) == llGetOwner()) {
            JSON = llJsonSetValue(JSON,["channel"],channel);
            JSON = llJsonSetValue(JSON,["message"],message);
            llMessageLinked(LINK_SET,TRANSMIT_PAGER,JSON,NULL_KEY);
        }
    }
    link_message(integer sender_number, integer num, string value, key id) {
        if(value == JSON) return;
        llOwnerSay(llJsonGetValue(value,["success"]));
    }
}
All Done! Once you have all those items in the prim, everything should be working. All you need to do now is to change the name of the channel to a channel in your own network.

Transmitting Messages

One of the major functions that this API will allow you to do is to transmit messages to other users who have pagers or speakers.
You can find the channel by going to your channels in your computer terminal and selecting Channels Then List.
You must use the Channel Names exactly the way you added them to the database.

Sending a Transmission

Sending a transmission is very simple once you have the hang of it.

Helpful Variables

There are some variables that are required to tell the API Script what you are trying to do.
The Numbers that you pass through the llLinkMessage() Function are the action that is sent to the API Script.
Variable List
  • TRANSMIT_PAGER = 21001 This action tells the API Script that you want to transmit a message to other pagers on a certain channel.
  • TRANSMIT_SPEAKER = 21002 This will tell the API Script to only send a message to the speakers.
  • TRANSMIT_ALL = 21003 This will send messages to all the devices on that channel.
Did you send a message and have it be a success? Here is the response.
{
    "success" : "Message has been successfully sent!"
}