Você está na página 1de 14

SMEStorage API description

API uses REST architecture model.

Manual Version 0.4.

New in version 0.4:


 Added description of function doFaxDocuments
New in version 0.3:
 Added description of function doPublicFile
New in version 0.2:
 Added description of function doShareFolderWithGroup
 Changed description of function getAllShared
Requests
API request is HTTP request of special formatted URL. The URL looks like
http://www.smetube.com/smestorage/api/token/function/arguments
token - special authentification string that can be get with special login request
function - string that identifies the request function
arguments - comma separated list of arguments that are encoded with base64 method

Important! Arguments order must be the same as in function description.

Request examples:
http://www.smetube.com/smestorage/api/*/gettoken/R2VsZW1ianVr,MjUxMjE5ODI=
Get token by login and password. There are login and password R2VsZW1ianVr,MjUxMjE5ODI= that are
base64 encoded.
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/getFilesList/
Get list of files and folders.
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doSendEmail/MTQ4,dG93Z
XIuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=,aGVsbG8=,
Send email to friend with link to file.

Responses
Response of the API is XML document (except successful file downloading).
Structure of the response:
<?xml version='1.0' encoding='UTF-8'?>
<response>
<status>ok</status>
<statusmessage>Status message</statusmessage>
...additional data...
</response>

Example:
<?xml version='1.0' encoding='UTF-8'?>
<response>
<status>ok</status>
<statusmessage>Success</statusmessage>
<function>getFilesList</function>
<length>17</length>
<filelist>
<n0>
<fi_id>78</fi_id>
<fi_pid>0</fi_pid>
<fi_uid>26</fi_uid>
<fi_name>111newname</fi_name>
<fi_s3name></fi_s3name>
<fi_extension></fi_extension>
<fi_description>222descr</fi_description>
<fi_type>1</fi_type>
<fi_created>2008-01-28 01:54:59</fi_created>
<fi_size>0</fi_size>
<fi_contenttype></fi_contenttype>
<fi_tags></fi_tags>
</n0>
<n1>
...
</filelist>
<us_size>4825455</us_size>
<pa_size>262144000</pa_size>
<tagcloud>
<n0>
<ta_fid>128</ta_fid>
<ta_name>test2</ta_name>
<ta_uid>26</ta_uid>
</n0>
<n1>
...
</tagcloud>
</response>

Alternative ways to make response


REST request can be made with alternative way by calling of the script
http://www.smetube.com/smestorage/api/rpc.php
and passing arguments with GET or POST method.
Main arguments names:
token,function,args
Also arguments can be individually without base64 encoding.
For example: to send email to friend call the API script with arguments:
token=1a3c5b2c5e64d5ecb56df380871594dc
function=doSendEmail
fi_id=123
friend_email=roman@gelembjuk.com
from_name=SMEAdmin
text=sea here
days=2

Detailed about each argument see below.


How it works
1. Client requests a token by passing login and password.
2. Servers check login info and return token or error
3. Client uses token in each API operations
4. Token expires in 30 minutes. Then client need to request token again.
API Functions

gettoken
Get token for opaerations.
In this function token must have value “*” .
Arguments:login,password
Example:
http://www.smetube.com/smestorage/api/*/gettoken/R2VsZW1ianVr,MjUxMj23ODI=
Success response parameters:
token - contains the token.

getFilesList
Return all files and folders with all attributes. Also returns all tags.
Arguments: folder id
If argument is not passed then all files and folders are returned.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/getFilesList/
Success response parameters:
XML structure with data of the database tables Files and Tags.

doSendEmail
Send email to friend with file download link.
Arguments: fileid,email,fromname,text,days
FileID can be comma separated list of ids. In this case links for each file will be included in email.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doSendEmail/MTQ4,dG93Z
XIuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=,aGVsbG8=,
Success response parameters:
Count of processed files.

doMoveFiles
Move file to another folder.
Arguments: fileid,folderid
FileID can be comma separated list of ids. In this case all files will be moved to folder
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doMoveFiles/MTQ4,dG93Z
X
Success response parameters:
Moved files info
doRenameFile
Rename file or change attributes (description,tags)
Arguments: fileid,filename,filedescription,filetags
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doRenameFile/MTQ4,dG93
ZX,FtGdRT,HtGfGjjtkj657jJHGmHGM
Success response parameters:
Altered file info

doDeleteFile
Delete file
Arguments: fileid
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doDeleteFile/MTQ4
Success response parameters:
Just status

doRenameFolder
Rename folder and change description
Arguments: folderid,foldername,folderdescription
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doRenameFolder/MTQ4,JK
kKKKKJG,JHkhLK34kHGK
Success response parameters:
Altered folder info

doDeleteFolder
Delete folder
Arguments:folderid
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dcdoDeleteFolder/MTQ4
Success response parameters:
Just status

doCreateNewFolder
Create folder
Arguments: foldername,folderdescription,parentfolderid
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doCreateNewFolder/MTQ4,
JKkKKKKJG,JHkhLK34kHGK,JHG7JH
Success response parameters:
New folder info
doUploadFiles
Upload the file.
This is the only request that need arguments are passed with POST method.
Form action URL to upload file is
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doUploadFiles/
Arguments:
fi_pid - parent folder id. If empty then is uploaded to root folder.
file_name1 - file name
file_desc1 - file description
file_tags1 - file tags (comma separated)
file_1 - name of attached file (name of input parameter of file type)

Also it is possible to upload more then 1 file (max. 5). IN this case use additional parameters with names
file_name2,file_desc2,... and so on.

getFile
Download the file.
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/getFile/MTQ4
Arguments:fileid
Response:
If file exists then response is actually file. If file doesn't exist then xml document with error message returned.

getGroupsList
Return all groups that has current user as the member
Arguments: no arguments
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/getGroupsList/
Success response parameters:
XML structure with data of the database table Groups. Each group item contains substructure with the list of
group members (user id and name)

getAllShared
Returns the list of all shared files. Returned data has three lists: files shared by current user, files shared for
current user and folders shared for user (each folder record contains the list of files and subfolders )
Arguments: no arguments

Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/getAllShared/
Success response parameters:
XML structure with data of the database table Shared .
doCreateGroup
Create new group
Arguments: group name,group description
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doCreateGroup/MTQ4,JKk
KKKKJG
Success response parameters:
New group info

doRenameGroup
Edit group info (name and description)
Arguments: group id, group name, group description
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doRenameGroup/RDtN,MT
Q4,JKkKKKKJG
Success response parameters:
Updated group info

doDeleteGroup
Delete group. Only the group creator can delete it.
Arguments: groupid
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doDeleteGroup/MTQ4
Success response parameters:
Just status

doInviteToGroup
Send email to friend with link to become a member of the group.
Arguments: group id,email,from name, text
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doInviteToGroup/MTQ4,dG
93ZXIuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=
Success response parameters:
Just status

doAcceptInvitation
Accept or refuse invitation to the group.
Arguments: invitation code, acceptance (y or n)
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doAcceptInvitation/dG93ZX
IuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=
Success response parameters:
Just status

doShareFileWithGroup
Share the file with the group or the user.
Arguments: group id, file id, count of days, comment, user id
If user id is 0 then file are shared with all members of the group otherwise only with specified user. If count
of days is 0 or empty then sharing is unlimited in time.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doShareFileWithGroup/MT
Q4,dG93ZX,dG93ZXIuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=
Success response parameters:
Shared file record.

doShareFolderWithGroup
Share the folder with the group or the user.
Arguments: group id, folder id, count of days, comment, user id, sharesubfolders
If user id is 0 then file are shared with all members of the group otherwise only with specified user. If count
of days is 0 or empty then sharing is unlimited in time.
Argument sharesubfolders can have values y or n . If y then subfolders are shared too.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doShareFileWithGroup/MT
Q4,dG93ZX,dG93ZXIuZ3J2QGdtYWlsLmNvbQ==,cm9tYW4=
Success response parameters:
Shared folder record with all files and subfolders (if subfolders are shared).

doDeleteShared
Delete shared file from shared files list (not delete file itself).
Arguments: shared item id
If shared file was shared by current user then it is deleted and no more accessed by other users. If user
deletes shared file (that was shared for him by another user) then file will be deleted just for him, not for other
group members.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doDeleteShared/MTQ4
Success response parameters:
Just status
doUnsubscribeGroup
Unsubscribe user from the group
Arguments: user id, group id
Group creator can’t unsubscribe itself. Only the group creator can unsubscribe users. Any user can
unsubscribe itself (except creator).
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ doUnsubscribeGroup
/MTQ4,WT5F
Success response parameters:
Status

getEmailAccounts
Returns the list of all email accounts.
Arguments: no arguments

Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ getEmailAccounts/
Success response parameters:
XML structure with data of the database table EmailAccounts .

doCreateEmailAccount
Create new email account
Arguments: account name, pop3 host, pop3 username, pop3 password, pop3 port
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doCreateEmailAccount/MT
Q4,JKkKKKKJG,JHG56GH,H3GH
Success response parameters:
New account info

doEditEmailAccount
Email account group info
Arguments: account id , account name, pop3 host, pop3 username, pop3 password, pop3 port
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ doEditEmailAccount /
MTQ4,JKkKKKKJG,JHG56GH,H3GH
Success response parameters:
Updated account info
doDeleteEmailAccount
Delete email account.
Arguments: account id
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ doDeleteEmailAccount
/MTQ4
Success response parameters:
Deleted account info

doBackupEmailBox
Backup emails from email account.
Arguments: account id
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ doBackupEmailBox /MTQ4
Success response parameters:
Amount of backuped emails

doPublicFile
Set or unset file as public
Arguments: file id, public state (0 or 1)
file id can be the list if comma separated ids of files.
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/ doPublicFile /MTQ4,HTF4
Success response parameters:
The list of changed files

doFaxDocuments
Fax documents
Arguments: file ids, recipients, faxheader
file ids can be the list if comma separated ids of files.
Recipients – the list of fax numbers (enter (return , “\n”) splitted ). Numbers must start with “+” symbol.
Faxheader – any string (can be empty)
Example:
http://www.smetube.com/smestorage/api/1a3c5b2c5e64d5ecb56df380871594dc/doFaxDocuments/MTQ4,H
TF4GJHG,KJGKJFKJ
Success response parameters:
The list of faxed files. Also the list of files where error occurred.
Arguments names to call functions with GET or POST method.

gettoken
us_login - login
us_pwd - password

doSendEmail
fi_id - fileid
friend_email - email
from_name - fromname
text - text
days - days

doMoveFiles
fi_ids - fileid
dir_id - folderid

doRenameFile
fi_id - fileid
fi_name - filename
fi_description - filedescription
fi_tags - filetags

doDeleteFile
fi_id - fileid

doRenameFolder
fi_id - folderid
fi_name - foldername
fi_description - folderdescription

doDeleteFolder
fi_id - folderid

doCreateNewFolder
fi_name - foldername
fi_description - folderdescription
fi_pid - parentfolderid
getFile
fi_id - fileid

doCreateGroup
gr_title - Title of the group
gr_description - Description of the group

doRenameGroup
gr_id - Group's ID
gr_title - Title of the group
gr_description - Description of the group

doDeleteGroup
gr_id - Group's ID

doInviteToGroup
gr_id - Group's ID
friend_email - email
from_name - from name
text - text

doAcceptInvitation
gr_code - Code of the invitation
accept - 'y' or 'n'

doShareFileWithGroup
gr_id - Group's ID
fi_id - File ID
gr_expired - Count of days (or 0 if unlimited)
gr_comment - Comment
us_id - User ID

doShareFolderWithGroup
gr_id - Group's ID
fi_id - File ID
gr_expired - Count of days (or 0 if unlimited)
gr_comment - Comment
us_id - User ID
sharewithsunfolders - Check if to share subfolders (y or n)

doDeleteShared
gr_sharedid - ID of shared item

doUnsubscribeGroup
gr_id - group identifier
us_id - user identifier

doCreateEmailAccount
em_name - account name
em_host - account pop3 host
em_username - account pop3 username
em_password - account pop3 password
em_port - account pop3 port

doEditEmailAccount
em_id - account id
em_name - account name
em_host - account pop3 host
em_username - account pop3 username
em_password - account pop3 password
em_port - account pop3 port

doDeleteEmailAccount
em_id - account id

doBackupEmailBox
em_id - account id

doFaxDocuments
fi_id - file id or comma separated ids
recipients - ‘return’ separated list of recipients
faxheader - fax header

Você também pode gostar