MyCloudPortal.NET offers a RESTful service for your remote applications to connect
and interact with your portal.
Before any methods may be called in the API, you must have a session key. To acquire
a session key, you will use the email address for your account and the API code
in the settings page of your portal. Requests for authentication will be in this
format:
http://www.mycloudportal.net/api/security/authenticate?email={email_address}&code={api_code}
After calling the authentication method, your local application will receive the
session key in an xml document:
<?xml version="1.0" encoding="UTF-8">
<string>78A863A0-7712-46CF-853D-8FF0CQS040E1_9_74</string>
With this session key, you will have secure access to any method in the API.
Example:
// Get the account's email login from the configuration file
string accountEmail = System.Configuration.ConfigurationSettings.AppSettings["accountEmail"];
// Get the account's API code from the configuration file
string accountCode = System.Configuration.ConfigurationSettings.AppSettings["accountCode"];
// Get the list of email addresses from the configuration file
string errorEmailList = System.Configuration.ConfigurationSettings.AppSettings["errorEmailList"];
// Get the 'from email' from the configuration file
string fromEmail = System.Configuration.ConfigurationSettings.AppSettings["fromEmail"];
// Create the authentication url
string url = "http://www.mycloudportal.net/api/security/authenticate?email="
+ accountEmail + "&code=" + accountCode;
// Send the request and get the response
string html = getWebPageHTML(url);
// Load the response into an xml document
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(html);
// Get the session key from the xml document
string sessionKey = doc.ChildNodes[1].InnerText;
// Loop through each email address
foreach (
string email
in errorEmailList.Split(';'))
{
// build the email send url and execute
url = "http://www.mycloudportal.net/api/email/sendToEmail?code=" + accountCode
+ "&sessionkey=" + sessionKey + "&FromEmail=" + fromEmail + "&ToEmail=" + email
+
"&subject=" + System.Web.HttpUtility.UrlEncode(subject) + "&body=" + System.Web.HttpUtility.UrlEncode(body);
html = getWebPageHTML(url);
}