FilesFrom API how to
The FilesFrom API allows anyone with a bit of programming experience to integrate FilesFrom in their own website or web application. We have provided quick integration and full integration methods, as well as a demo to show how the API works. Have fun!
Quick Integration
Introduction
The following example will only allow you to send file via the FilesFrom API. It does not have the ability to register any new users, change password, or get a list of contacts. To understand more about these features please refer to the examples in the Full Integration section.
To get going only two things are required:
- A web form: capture your filesfrom API code, user's credentials and the details of the file.
- An iFrame: If you don't use an iFrame, the page will be redirected to us.filesfrom.com.
<input type="text" name="api_code" id="api_code" value="[your 32 digit API code]" />
<input type="text" name="email" id="email" />
<input type="password" name="password" id="password" />
<input type="text" name="receiverEmails" id="receiverEmails" />
<input type="text" name="message" id="message" />
<input type="file" id="fileFile" name="fileFile" />
<input type="text" name="succeededFunc" id="succeededFunc" />
<input type="text" name="failedFunc" id="failedFunc" />
<input type="submit" name="btnSubmit" id="btnSubmit" value="Send File" />
</form>
<iframe id="upload_iframe" name="upload_iframe" width="0" height="0" frameborder="0" style="width:0px; height:0px; border:0px;"></iframe>
Authentication: These fields are mandatory. For more information regarding the API code, please visit us.filesfrom.com.
- api_code: This is your 32 digit API code from FilesFrom.
- password An MD5 hash of the user's FilesFrom password.
File Details
- receiverEmails: Receiver's email address. If there is more than one they are seperated by a comma, e.g. "john.smith@test.com.au,jane.citizen@test.com.au".
- message This message will appear on the email sent out to the receiver(s). (optional)
- fileFile The actual file to be sent.
Post upload action
- succeededFunc: Once the file is sent successfully, the parsed function name will be executed.
- failedFunc If there is any errors occur, the parsed function name will be called.
Full Integration
Introduction
In addition to the reqirements in the Quick Integration section, you'll need another iFrame to load the FilesFrom Javascript library.
This library enables you to integrate with FilesFrom via simple Javascript function calls.
How to use
You can use the library by placing the following line in your page.
Please note: It is advisable for the id and name have the same value.
The following functions are ready for you to use once the iFrame is loaded. The function names are self-explanatory.
- MD5(string)
- ff_registration(api_code, email, func)
- ff_login(api_code, email, password, func)
- ff_changePassword(api_code, email, password, new_password, func)
- ff_recoverPassword(api_code, email, func)
- ff_getContactList(api_code, email, password, func)
- ff_getSendQuota(api_code, email, password, func)
- ff_getSizeQuota(api_code, email, password, func)
- ff_getSentList(api_code, email, password, func)
You can call any functions via `iframe_name.function_name`. Based on the previous example, you can retrieve a list of sent files via filesfrom.ff_getSentList(...).
Authentication
- api_code: This is your 32 digit API code from FilesFrom.
- password A MD5 hash of the user's filesfrom password. MD5() hashing function is provided in the library, e.g. filesfrom.MD5(...).
Argument
You will notice the last arguments of any functions is called func. It is a function reference to handle any results returned.
See example below for more details.
Example
Results are returned in a JSON object (click here for more information). Since JSON is a subset of JavaScript's object literal notation, you can recreate the object via eval():
Here is an example (object name is based on previous example):
function processSentList(ret)
{
var p = eval("(" + ret.responseText + ")");
}
</script>
<input type="button" value="Get Sent List" onclick="filesfrom.ff_getSentList('xxxx', 'john.smith@test.com.au', 'xxxxx', processSentList)" />
- When the user clicks on the `Get Sent List` button, `ff_getSentList()` will be called.
- Once `ff_getSentList()` finishes, it calls `processSentList()` and the result (JSON object) is stored in the responseText property.
- `processSentList()` assigns the result into variable j by calling eval().
Demo
In this demo api_code, email and password are already supplied. Your website or web application should ask the user to enter their FilesFrom email and password.
Please note: this demo only shows you the format of any JSON results. It does not send or insert any records into FilesfFrom and all files are removed after the upload is completed.
Quick File Send
FilesFrom functions
- ff_registration(api_code, email, func)
- ff_login(api_code, email, password, func)
- ff_changePassword(api_code, email, password, new_password, func)
- ff_recoverPassword(api_code, email, func)
- ff_getContactList(api_code, email, password, func)
- ff_getSizeQuota(api_code, email, password, func)
- ff_getSendQuota(api_code, email, password, func)
- ff_getSentList(api_code, email, password, func)