network API examples

Following listings presents how to use network features of the robot's modules using robot structure. First one presents how to check weather and news utilizing UBrowser module.

//example shows how to weather forecast or news can be easily read thanks to robot structure;//we simpy call to get new weather forecast
//now we can access the forecast by reading consecutive weather parameters, e.g.
//we can also read overall weather forecast for next days
var tmp_forecast =;//for the next day
echo("Day "+ tmp_forecast[0]);
echo("Date "+ tmp_forecast[1]);
echo("Lowest temp "+ tmp_forecast[2]);
echo("Highest temp "+ tmp_forecast[3]);
echo("Condition "+ tmp_forecast[4]);
echo("Condition code "+ tmp_forecast[5]);
//in similar matter we read news from rss channels:
//we get news from desired address"");//get news from Sky News 
//Now we can simply check if there are some news
if (!=0)
echo([0]);//and read their title
echo([0]);//and content

The following listing presents how to send and receive e-mails via robot structure.

//the examples show how to use robot mail box, in case of using user mail box instead, replace "robot" with "user"
//fill the standard e-mail fields:["robot"].send.From("I Robot");["robot"].send.To(["[at]","another.example[at]"]);["robot"].send.Cc([]);["robot"].send.Bcc([]);["robot"].send.Subject("Hi! It's me");["robot"].send.Content("I am a funny robot!<br /> Please check my attachment.<br /><br /><strong><em>I Robot</em></strong>");["robot"].send.Attachment(["me.jpg"]);["robot"].Send();
//the above procedure is standard regardless the utilized mail module - UMail (POCO)/UMail (CURL)
//when using UMAIL (CURL) you can give your attachments unique ID and add them to mail content (e.g. picture will be displayed inside the e-mail, not presented as a file in attachment list)["robot"].send.Content("<img src="cid:ID_XXX_XXX" alt="" /><br /><br /><b><i>My Robot</i></b>");["robot"].send.Attachment(["saved/photo.jpg"]);["robot"].send.AttachmentID(["ID_XXX_XXX"]);
//Receiving e-mail utilizing POCO module
var tmp_number =["robot"].receive.newNo;//number of new emails["robot"].Receive(); //we download all new e-mails["robot"].receive.SaveAttachments("path/to/save/");//and save attachments
//all fields of["robot"].receive receive vectors of information - we read them one by one
for(var i = 0; iter<tmp_number; i++)
echo ("E-mail no: " + i);
echo ("From: "+["robot"].receive.From[i]);
echo ("Subject: "+["robot"].receive.Subject[i]);
echo ("Content: "+["robot"].receive.Content[i]);
//Receiving e-mail utilizing CURL module
var tmp_ids =["robot"].receive.ID; //vector of IDs of new e-mails in mailbox
var tmp_number = ids.size();//number of new e-mails
for(var i = 0; iter<tmp_number; i++)
{["robot"].Receive(tmp_ids[i]);//we download from server one e-mail with ID from vector of avaliable IDs["robot"].receive.SaveAttachments(tmp_ids[i],"path/to/save/");//we also save attachments
echo ("E-mail no: " + i);
//this time fields contain information only about last downloaded e-mail
echo ("From: "+["robot"].receive.From);
echo ("Subject: "+["robot"].receive.Subject);
echo ("Content: "+["robot"].receive.Content);

The following listing presents how to use features of Facebook module using robot structure

//the examples show how to use robot Facebook, in case of using user Facebook instead, simply replace "robot" with "user"["robot"].notification.Get(); //get robot notifications
echo(["robot"].notification.fromName[0]);//print the full information about source of first notification
echo(["robot"].notification.title[0]);//print the title of first notification["robot"].album.Get();//get all robot's albums["robot"].photo.Get(["robot"].album.ID[0]);//get all photos from the first album["robot"].photo.Put(["robot"].album.ID[0]),"It's me.","image.jpg");//put photo "image.jpg" in first album with description "It's me."["robot"].post.GetFeed();//get all things that robot might see on his own wall
echo(["robot"].post.fromName[0]);//print the user full name who posted first post
echo(["robot"].post.message[0]);//print the content of first message["robot"].post.PutPost("Hello");//put post on robots wall["robot"].like.Put(["robot"].post.ID[0]);//like the first of the read posts["robot"].comment.Put(["robot"].post.ID[0],"It's me!");//comment the first post on Facebook

The following listing presents how to access Google calendar and contacts features via robot structure.

//examples show how to use user calendar and contacts["user"].calendar.Get();//we get information about robot calendars["user"].event.Get(["user"].calendar.ID,".")[0],"");//we get all events from the first calendar which are starting today or later
//we display info about first event 
//we set event in primary calendar["user"].event.set("primary","Meeting","Wroclaw","2014-08-22 08:00:00","2014-08-22 10:00:00",15,-1,-1);//send e-mail 15 minutes before meeting, do not remind via popup or sms
//we set whole day event in primary calendar["user"].event.set("primary","Delegation","London","2014-08-01","2014-08-10",-1,-1,-1);//-1,-1,-1 means that we do not want any reminder of event
//accessing Google contacts["user"].group.Get();//get user contacts groups["user"].contact.Get(["user"].group.ID[0]);//get contacts from first group
//print data of first contact from first group



EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.9.2, 23.11.2017

FLASH Documentation