Difference between revisions of "SOAP API"

From 4shared wiki
Jump to: navigation, search
(Android)
(getItems)
 
(34 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
4shared API is totaly free! All required samples you may find at 4shared API documentation. Any questions regarding 4shared developer program you may discuss at our forum.
 
4shared API is totaly free! All required samples you may find at 4shared API documentation. Any questions regarding 4shared developer program you may discuss at our forum.
  
Every month we will pick best app with 4shared API and award developer  
+
Every month we will pick best app with 4shared API (the more inserted key 4shared functions, the better) and award developer  
 
for $5,000! We pay $5,000/month for best app.
 
for $5,000! We pay $5,000/month for best app.
  
 
__TOC__
 
__TOC__
 
  
 
== Sources ==
 
== Sources ==
Line 41: Line 40:
  
 
5. Write your own fresh and brilliant application
 
5. Write your own fresh and brilliant application
 +
 +
6.''' Important! You must include the following into the app''':
 +
 +
'''Check the simple example:'''
 +
 +
let's have the user app_name_test have password 1,
 +
 +
where app_name - is the name of your application.
 +
 +
user enters his credentials as:
 +
 +
'''login:''' "app_name_test "
 +
 +
'''password:''' "1"
 +
 +
You should silently add designator for your to user provided password.
 +
 +
So, you will send:
 +
 +
login: "app_name_test "
 +
 +
password: "!!!app_name!!:1"
 +
 +
for any function, which needs password.
  
 
== Samples ==
 
== Samples ==
Line 71: Line 94:
 
----  
 
----  
 
=== iOS ===
 
=== iOS ===
 +
 +
----
 +
 
Every application in iOS can use 4shared service. The client can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions. These functions may be used to request for the content of your account, get the necessary links to files, and edit the file structure and the directory properties on the server. The full description of the api is provided here (link to http://help.4shared.com/index.php/SOAP_API). The SOAP-protocol may be checked here (link to http://en.wikipedia.org/wiki/SOAP).
 
Every application in iOS can use 4shared service. The client can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions. These functions may be used to request for the content of your account, get the necessary links to files, and edit the file structure and the directory properties on the server. The full description of the api is provided here (link to http://help.4shared.com/index.php/SOAP_API). The SOAP-protocol may be checked here (link to http://en.wikipedia.org/wiki/SOAP).
  
Line 252: Line 278:
 
</pre>
 
</pre>
  
The demo-sample can be downloaded here ('''link to the demo-project archive''').  
+
The demo-sample can be downloaded here (http://dc243.4shared.com/download/ecV5Tw4I/ios_samples.zip).  
  
 
To start the sample application, enter demo-Prefix.pch in the file, enter your login and password from the site 4shared (macros LOGIN and PASSWORD).
 
To start the sample application, enter demo-Prefix.pch in the file, enter your login and password from the site 4shared (macros LOGIN and PASSWORD).
 
----
 
----
 +
 
=== Symbian (QT) ===
 
=== Symbian (QT) ===
 +
 +
----
  
 
Every application can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions.  
 
Every application can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions.  
Line 468: Line 497:
 
</pre>
 
</pre>
  
Demo-sample can be downloaded here ('''link to the demo-project archive''').  
+
Demo-sample can be downloaded here (http://dc243.4shared.com/download/bFbwuFVS/symbian_Qt_example.zip).  
  
 
'''To start the sample application''', insert your login and password from 4shared in the file MainWindow.cpp (variable login and password).
 
'''To start the sample application''', insert your login and password from 4shared in the file MainWindow.cpp (variable login and password).
  
 
----
 
----
 
  
 
=== Android ===
 
=== Android ===
 +
 +
----
 +
  
 
1. '''4shared API.'''  
 
1. '''4shared API.'''  
 +
  
 
Service 4shared is a usual web-service, '''WSDL description''' of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.  
 
Service 4shared is a usual web-service, '''WSDL description''' of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.  
Line 490: Line 522:
  
 
'''2. Tools for Development.'''
 
'''2. Tools for Development.'''
 +
  
 
Development of applications for Android is possible on any platform, which allows Andrid SDK setup.  
 
Development of applications for Android is possible on any platform, which allows Andrid SDK setup.  
Line 517: Line 550:
 
3) Create a New Android Project (http://developer.android.com/resources/tutorials/hello-world.html)
 
3) Create a New Android Project (http://developer.android.com/resources/tutorials/hello-world.html)
  
[ image1 ]
+
[[Image:Image1.png]]
  
 
4) To insert changes, needed to make the minimum 4shared-application work  
 
4) To insert changes, needed to make the minimum 4shared-application work  
Line 523: Line 556:
 
To link the ksoap2 library to the project, it’s necessary to create subcatalog libs in the catalogue Hello4shared and place jar-archive of this library there. Then, choose Project > Options in menu Eclipse, and after that select subsection Java Build Path and tab Libraries. Press the button '''Add JARs''' and display the path to the library.  
 
To link the ksoap2 library to the project, it’s necessary to create subcatalog libs in the catalogue Hello4shared and place jar-archive of this library there. Then, choose Project > Options in menu Eclipse, and after that select subsection Java Build Path and tab Libraries. Press the button '''Add JARs''' and display the path to the library.  
 
      
 
      
[ image2 ]
+
[[Image:Image2.png]]
  
 
With the help of menu File > New > Class, let’s''' create 2 subclasses''': '''AccountItem''', representing the user’s file or catalogue on 4shared server, and '''ForSharedService''', with the help of which 4shared API remote methods are called up.
 
With the help of menu File > New > Class, let’s''' create 2 subclasses''': '''AccountItem''', representing the user’s file or catalogue on 4shared server, and '''ForSharedService''', with the help of which 4shared API remote methods are called up.
Line 781: Line 814:
  
 
To do that, let’s create the new class (File > New > Class), derivative from ListActivity, in Eclipse environment, and call it AccountContents.
 
To do that, let’s create the new class (File > New > Class), derivative from ListActivity, in Eclipse environment, and call it AccountContents.
   
+
     
[ image ]
+
 
   
+
 
Let’s '''edit AccountContents.java''', by redefining the method '''onCreate''', called up by means of initializing the window (activity).
 
Let’s '''edit AccountContents.java''', by redefining the method '''onCreate''', called up by means of initializing the window (activity).
  
Line 919: Line 951:
 
</pre>
 
</pre>
  
The full code of the demo-application is attached.  
+
The full code of the demo-application is attached (http://dc243.4shared.com/download/l8R381Nw/androidsamples.zip).
  
  
 
5. '''Run the Application''' (http://developer.android.com/resources/tutorials/hello-world.html)
 
5. '''Run the Application''' (http://developer.android.com/resources/tutorials/hello-world.html)
  
[ image3 ]
+
[[Image:Image3.png]]
 +
 
  
 
----
 
----
 
  
 
=== Blackberry ===
 
=== Blackberry ===
  
 +
----
  
'''Software SetUp'''
 
  
'''System requirements:'''  
+
'''System requirements:'''
 +
  
 
- 32-bit Windows® XP, Windows Vista® or Windows 7 (64-bit versions require 32-bit Java® и Eclipse)
 
- 32-bit Windows® XP, Windows Vista® or Windows 7 (64-bit versions require 32-bit Java® и Eclipse)
Line 946: Line 979:
  
 
'''Setup:'''
 
'''Setup:'''
 +
  
 
-Download and install 32-bit version of JAVA  (http://www.java.com/ru/download/)
 
-Download and install 32-bit version of JAVA  (http://www.java.com/ru/download/)
Line 957: Line 991:
  
  
'''Description of 4shared Service'''
+
'''1. Description of 4shared Service'''
 +
 
  
 
Service 4shared is a usual web-service, '''WSDL description''' of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.  
 
Service 4shared is a usual web-service, '''WSDL description''' of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.  
Line 969: Line 1,004:
  
  
'''1. Demo Application'''
+
'''2. Demo Application'''
  
  
Line 978: Line 1,013:
 
To work with the service, it’s necessary to add ''' subclass ForSharedService'''.  
 
To work with the service, it’s necessary to add ''' subclass ForSharedService'''.  
  
The standard call of the function 4shared API will be the following:
+
The s'''tandard call of the function 4shared API''' will be the following:
  
 
<pre>
 
<pre>
Line 1,088: Line 1,123:
 
</pre>
 
</pre>
  
And the exact request to 4shared service in the method login, by means of using the class ForSharedService, described above:
+
And the '''exact request to 4shared service''' in the method login, by means of using the class ForSharedService, described above:
  
 
<pre>
 
<pre>
Line 1,109: Line 1,144:
 
In case of invalid login or password, the user will receive the error report.
 
In case of invalid login or password, the user will receive the error report.
  
The '''full code''' of the demo-application is attached.
+
The '''full code''' of the demo-application is attached (http://dc315.4shared.com/download/bjixhTFj/blackberrysamples.zip).
  
  
Line 1,116: Line 1,151:
 
== '''Method Summary''' ==
 
== '''Method Summary''' ==
  
== addToFavorites ==
+
=== addToFavorites ===
 
long addToFavorites(java.lang.String login, java.lang.String password, long fileId)  
 
long addToFavorites(java.lang.String login, java.lang.String password, long fileId)  
 
Adds file to user favorites.
 
Adds file to user favorites.
  
== addToMyAccount ==
+
=== addToMyAccount ===
 
java.lang.String addToMyAccount(java.lang.String login, java.lang.String password, long dirId, java.lang.String link)  
 
java.lang.String addToMyAccount(java.lang.String login, java.lang.String password, long dirId, java.lang.String link)  
 
Adds file or folder identified by supplied link to user's account in folder identified by dirId
 
Adds file or folder identified by supplied link to user's account in folder identified by dirId
  
== checkSharedDirAccess ==
+
=== checkSharedDirAccess ===
 
int checkSharedDirAccess(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword)  
 
int checkSharedDirAccess(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword)  
 
Checks if directory can be accessed by specified user with specified passwords
 
Checks if directory can be accessed by specified user with specified passwords
 
   
 
   
== createNewFolder ==
+
=== createNewFolder ===
 
long createNewFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String folderName)  
 
long createNewFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String folderName)  
 
Creates new folder as dirId subfolder
 
Creates new folder as dirId subfolder
 
   
 
   
== createUploadSessionKey ==
+
=== createUploadSessionKey ===
 
java.lang.String createUploadSessionKey(java.lang.String login, java.lang.String password, long dirID)  
 
java.lang.String createUploadSessionKey(java.lang.String login, java.lang.String password, long dirID)  
 
Creates session key for uploading file
 
Creates session key for uploading file
  
== decodeId ==
+
=== decodeId ===
 
java.lang.String decodeId(java.lang.String login, java.lang.String password, java.lang.String encodedId)  
 
java.lang.String decodeId(java.lang.String login, java.lang.String password, java.lang.String encodedId)  
 
turns new encoded folder id into form id+"/"+4shared_password for shared folder browsing encoded folder id can be found as 8-symbol group of folder url right after /dir/ regexp: http://www.4shared.com/dir/(.{8,8})/.*
 
turns new encoded folder id into form id+"/"+4shared_password for shared folder browsing encoded folder id can be found as 8-symbol group of folder url right after /dir/ regexp: http://www.4shared.com/dir/(.{8,8})/.*
  
== decodeLink ==
+
=== decodeLink ===
 
long decodeLink(java.lang.String login, java.lang.String password, java.lang.String link)  
 
long decodeLink(java.lang.String login, java.lang.String password, java.lang.String link)  
 
Used to get item id from item link.
 
Used to get item id from item link.
  
== deleteFile ==
+
=== deleteFile ===
 
void deleteFile(java.lang.String login, java.lang.String password, long fileID)  
 
void deleteFile(java.lang.String login, java.lang.String password, long fileID)  
 
Removes file to recycle bin
 
Removes file to recycle bin
  
==deleteFileFinal==
+
=== deleteFileFinal ===
 
void deleteFileFinal(java.lang.String login, java.lang.String password, long fileID)  
 
void deleteFileFinal(java.lang.String login, java.lang.String password, long fileID)  
 
Remove file once and for all.
 
Remove file once and for all.
  
== deleteFolder ==
+
=== deleteFolder ===
 
void deleteFolder(java.lang.String login, java.lang.String password, long dirID)  
 
void deleteFolder(java.lang.String login, java.lang.String password, long dirID)  
 
Completely removes folder and puts all of it contents to recycle bin
 
Completely removes folder and puts all of it contents to recycle bin
  
== deleteFolderFinal ==
+
=== deleteFolderFinal ===
 
void deleteFolderFinal(java.lang.String login, java.lang.String password, long dirID)  
 
void deleteFolderFinal(java.lang.String login, java.lang.String password, long dirID)  
 
Removes files and subfolders from recycle bin.
 
Removes files and subfolders from recycle bin.
  
== downloadFinished ==
+
=== downloadFinished ===
 
void downloadFinished(java.lang.String login, java.lang.String password, long fileId)  
 
void downloadFinished(java.lang.String login, java.lang.String password, long fileId)  
 
Have to be called after full file download
 
Have to be called after full file download
  
== emptyRecycleBin ==
+
=== emptyRecycleBin ===
 
int emptyRecycleBin(java.lang.String login, java.lang.String password)  
 
int emptyRecycleBin(java.lang.String login, java.lang.String password)  
 
Empties recycle bean for specified user.
 
Empties recycle bean for specified user.
  
== getAllFolders ==
+
=== getAllFolders ===
 
AccountItem[] getAllFolders(java.lang.String login, java.lang.String password)  
 
AccountItem[] getAllFolders(java.lang.String login, java.lang.String password)  
 
Returns all of the folders in user's root directory
 
Returns all of the folders in user's root directory
 
   
 
   
== getAllItems ==
+
=== getAllItems ===
 
AccountItem[] getAllItems(java.lang.String login, java.lang.String password)  
 
AccountItem[] getAllItems(java.lang.String login, java.lang.String password)  
 
Returns info about all items in user's root folder
 
Returns info about all items in user's root folder
  
== getDirDescription ==
+
=== getDirDescription ===
 
java.lang.String getDirDescription(java.lang.String login, java.lang.String password, long dirId)  
 
java.lang.String getDirDescription(java.lang.String login, java.lang.String password, long dirId)  
 
Returns folder description
 
Returns folder description
  
== getDirectLink ==
+
=== getDirectLink ===
 
java.lang.String getDirectLink(java.lang.String login, java.lang.String password, java.lang.String link)  
 
java.lang.String getDirectLink(java.lang.String login, java.lang.String password, java.lang.String link)  
 
Returns link to start immediate downloading.
 
Returns link to start immediate downloading.
  
== getDirInfo ==
+
=== getDirInfo ===
 
AccountItem getDirInfo(java.lang.String login, java.lang.String password, long dirID)  
 
AccountItem getDirInfo(java.lang.String login, java.lang.String password, long dirID)  
 
Return info about specified folder
 
Return info about specified folder
  
== getExifFileInfo ==
+
=== getExifFileInf ===
 
ExifInfo getExifFileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink)  
 
ExifInfo getExifFileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink)  
 
Return image info for specified file link if any
 
Return image info for specified file link if any
  
 
+
=== getExifFileInfos ===
== getExifFileInfos ==
+
 
ExifInfo[] getExifFileInfos(java.lang.String login, java.lang.String password, long dirId)  
 
ExifInfo[] getExifFileInfos(java.lang.String login, java.lang.String password, long dirId)  
 
Returns @see ExifInfo for all image files in specified folder
 
Returns @see ExifInfo for all image files in specified folder
  
==getFavorites==
+
=== getFavorites ===
 
AccountItem[] getFavorites(java.lang.String login, java.lang.String password)  
 
AccountItem[] getFavorites(java.lang.String login, java.lang.String password)  
 
Returns user favored files.
 
Returns user favored files.
  
== getFileDescription ==
+
=== getFileDescription ===
 
java.lang.String[] getFileDescription(java.lang.String login, java.lang.String password, long fileId)  
 
java.lang.String[] getFileDescription(java.lang.String login, java.lang.String password, long fileId)  
 
Returns file title, tags and description if any
 
Returns file title, tags and description if any
  
== getFileDownloadLink ==
+
=== getFileDownloadLink ===
 
java.lang.String getFileDownloadLink(java.lang.String login, java.lang.String password, long fileID)  
 
java.lang.String getFileDownloadLink(java.lang.String login, java.lang.String password, long fileID)  
 
Returns download link for user owned file
 
Returns download link for user owned file
  
== getFileInfo ==  
+
=== getFileInfo ===  
 
AccountItem getFileInfo(java.lang.String login, java.lang.String password, long fileID)  
 
AccountItem getFileInfo(java.lang.String login, java.lang.String password, long fileID)  
 
Returns info about file
 
Returns info about file
  
== getFiles ==
+
=== getFiles ===
 
AccountItem[] getFiles(java.lang.String login, java.lang.String password, long[] fileIds)  
 
AccountItem[] getFiles(java.lang.String login, java.lang.String password, long[] fileIds)  
 
Returns account items for file ids.
 
Returns account items for file ids.
  
== getFreeSpace ==
+
=== getFreeSpace ===
 
long getFreeSpace(java.lang.String login, java.lang.String password)  
 
long getFreeSpace(java.lang.String login, java.lang.String password)  
 
Gets free space left for user
 
Gets free space left for user
  
== getItemInfo ==
+
=== getItemInfo ===
 
AccountItem getItemInfo(java.lang.String login, java.lang.String password, long itemID, boolean dir)  
 
AccountItem getItemInfo(java.lang.String login, java.lang.String password, long itemID, boolean dir)  
 
Common method for DesktopApp.getFileInfo(String, String, long) and DesktopApp.getDirInfo(String, String, long) distinguished by value of dir parameter
 
Common method for DesktopApp.getFileInfo(String, String, long) and DesktopApp.getDirInfo(String, String, long) distinguished by value of dir parameter
  
== getItems ==
+
=== getItems ===
 
AccountItem[] getItems(java.lang.String login, java.lang.String password, long dirID)  
 
AccountItem[] getItems(java.lang.String login, java.lang.String password, long dirID)  
 
Returns array of infos about contents of specified dir.
 
Returns array of infos about contents of specified dir.
  
== getItemsCount ==
+
=== getSharedDirItems ===
 +
 
 +
AccountItem[] getDirLinkItems(String dirLink, String userDirPassword).
 +
Returns array of infos about contents of specified dir accepting the folder link.
 +
 
 +
=== getItemsCount ===
 
long getItemsCount(java.lang.String login, java.lang.String password, long dirID)  
 
long getItemsCount(java.lang.String login, java.lang.String password, long dirID)  
 
Returns item count for dirId (-1 for root folder)
 
Returns item count for dirId (-1 for root folder)
  
== getItemsPartial ==
+
=== getItemsPartial ===
 
AccountItem[] getItemsPartial(java.lang.String login, java.lang.String password, long dirId, int startIndex, int count)  
 
AccountItem[] getItemsPartial(java.lang.String login, java.lang.String password, long dirId, int startIndex, int count)  
 
Get specified count folders' items ordered by name, folders first starting from startIndex
 
Get specified count folders' items ordered by name, folders first starting from startIndex
  
== getMaxFileSize ==
+
=== getMaxFileSize ===
 
long getMaxFileSize(java.lang.String login, java.lang.String password)  
 
long getMaxFileSize(java.lang.String login, java.lang.String password)  
 
Return maximum allowed file size for specified user
 
Return maximum allowed file size for specified user
  
== getMp3FileInfo ==
+
=== getMp3FileInfo ===
 
Mp3Info getMp3FileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink)  
 
Mp3Info getMp3FileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink)  
 
Return audio info for specified file link if any
 
Return audio info for specified file link if any
  
== getMp3FileInfos ==
+
=== getMp3FileInfos ===
 
Mp3Info[] getMp3FileInfos(java.lang.String login, java.lang.String password, long dirId)  
 
Mp3Info[] getMp3FileInfos(java.lang.String login, java.lang.String password, long dirId)  
 
Returns audio info for all audio files in folder
 
Returns audio info for all audio files in folder
 
   
 
   
== getNewFileDataCenter ==
+
=== getNewFileDataCenter ===
 
long getNewFileDataCenter(java.lang.String login, java.lang.String password)  
 
long getNewFileDataCenter(java.lang.String login, java.lang.String password)  
 
Returns datacenter id to upload files to
 
Returns datacenter id to upload files to
  
== getNotOwnedSizeLimit ==
+
=== getNotOwnedSizeLimit ===
 
long getNotOwnedSizeLimit()  
 
long getNotOwnedSizeLimit()  
 
Max file size which can be downloaded without speed limit
 
Max file size which can be downloaded without speed limit
  
== getPreviewLink ==
+
=== getPreviewLink ===
 
java.lang.String getPreviewLink(java.lang.String login, java.lang.String password, long fileId)  
 
java.lang.String getPreviewLink(java.lang.String login, java.lang.String password, long fileId)  
 
Return link to small preview image, or to flv preview for video files
 
Return link to small preview image, or to flv preview for video files
  
== getRecycleBinItems ==
+
=== getRecycleBinItems ===
 
AccountItem[] getRecycleBinItems(java.lang.String login, java.lang.String password)  
 
AccountItem[] getRecycleBinItems(java.lang.String login, java.lang.String password)  
 
Returns info about files in recycle bin
 
Returns info about files in recycle bin
  
== getRoot ==
+
=== getRoot ===
 
AccountItem getRoot(java.lang.String login, java.lang.String password)  
 
AccountItem getRoot(java.lang.String login, java.lang.String password)  
 
Returns account item for user's root directory
 
Returns account item for user's root directory
  
== getSharedDirItems ==
+
=== getSharedDirItems ===
 
AccountItem[] getSharedDirItems(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword)  
 
AccountItem[] getSharedDirItems(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword)  
 
Return content of possibly not owned shared folder
 
Return content of possibly not owned shared folder
  
== getSpaceLimit ==
+
=== getSpaceLimit ===
 
long getSpaceLimit(java.lang.String login, java.lang.String password)  
 
long getSpaceLimit(java.lang.String login, java.lang.String password)  
 
Returns user space limit
 
Returns user space limit
  
== getUploadFormUrl ==
+
=== getUploadFormUrl ===
 
java.lang.String getUploadFormUrl(int dataCenterID, java.lang.String sessionKey)  
 
java.lang.String getUploadFormUrl(int dataCenterID, java.lang.String sessionKey)  
 
Returns url to upload file to.
 
Returns url to upload file to.
  
== hasRightUpload ==
+
=== hasRightUpload ===
 
boolean hasRightUpload()  
 
boolean hasRightUpload()  
 
Whether upload feature is on.
 
Whether upload feature is on.
  
== isAccountActive ==
+
=== isAccountActive ===
 
boolean isAccountActive(java.lang.String login, java.lang.String password)  
 
boolean isAccountActive(java.lang.String login, java.lang.String password)  
 
Checks account active status
 
Checks account active status
  
== isAccountBanned ==
+
=== isAccountBanned ===
 
boolean isAccountBanned(java.lang.String login, java.lang.String password)  
 
boolean isAccountBanned(java.lang.String login, java.lang.String password)  
 
Checks if user account is banned
 
Checks if user account is banned
  
== isAccountPremium ==
+
=== isAccountPremium ===
 
boolean isAccountPremium(java.lang.String login, java.lang.String password)  
 
boolean isAccountPremium(java.lang.String login, java.lang.String password)  
 
Checks if user account is premium
 
Checks if user account is premium
  
== isExistsLoginPassword ==
+
=== isExistsLoginPassword ===
 
boolean isExistsLoginPassword(java.lang.String login, java.lang.String password)  
 
boolean isExistsLoginPassword(java.lang.String login, java.lang.String password)  
 
true-false version of login.
 
true-false version of login.
  
== login ==
+
=== login ===
 
java.lang.String login(java.lang.String login, java.lang.String password)  
 
java.lang.String login(java.lang.String login, java.lang.String password)  
 
Login version with diagnostic message.
 
Login version with diagnostic message.
  
== pasteFilesDirs ==
+
=== pasteFilesDirs ===
 
java.lang.String pasteFilesDirs(java.lang.String login, java.lang.String password, long toFolderId, boolean makeCopy, long[] fileIds, long[] dirIds)  
 
java.lang.String pasteFilesDirs(java.lang.String login, java.lang.String password, long toFolderId, boolean makeCopy, long[] fileIds, long[] dirIds)  
 
Copy-pastes or cut-pastes a group of files and dirs.
 
Copy-pastes or cut-pastes a group of files and dirs.
  
== removeFromFavorites ==
+
=== removeFromFavorites ===
 
long removeFromFavorites(java.lang.String login, java.lang.String password, long fileId)  
 
long removeFromFavorites(java.lang.String login, java.lang.String password, long fileId)  
 
Removes file from user's favorites.
 
Removes file from user's favorites.
  
== renameFile ==
+
=== renameFile ===
 
long renameFile(java.lang.String login, java.lang.String password, long fileID, java.lang.String newName)  
 
long renameFile(java.lang.String login, java.lang.String password, long fileID, java.lang.String newName)  
 
Renames specified file
 
Renames specified file
  
== renameFolder ==
+
=== renameFolder ===
 
long renameFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String newName)  
 
long renameFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String newName)  
 
Renames specified folder
 
Renames specified folder
  
== restoreFile ==
+
=== restoreFile ===
 
void restoreFile(java.lang.String login, java.lang.String password, long fileID)  
 
void restoreFile(java.lang.String login, java.lang.String password, long fileID)  
 
Restores file from Recycle Bin.
 
Restores file from Recycle Bin.
  
== restoreFiles ==
+
=== restoreFiles ===
 
void restoreFiles(java.lang.String login, java.lang.String password, long[] fileIDs)  
 
void restoreFiles(java.lang.String login, java.lang.String password, long[] fileIDs)  
 
Restores group of files from Recycle Bin.
 
Restores group of files from Recycle Bin.
  
== setDirDescription ==
+
=== setDirDescription ===
 
java.lang.String setDirDescription(java.lang.String login, java.lang.String password, long dirId, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll)  
 
java.lang.String setDirDescription(java.lang.String login, java.lang.String password, long dirId, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll)  
 
Sets folder description for dedicated folder or account as a whole
 
Sets folder description for dedicated folder or account as a whole
  
== setFileDescription ==
+
=== setFileDescription ===
 
java.lang.String setFileDescription(java.lang.String login, java.lang.String password, long fileId, java.lang.String title, java.lang.String tags, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll)  
 
java.lang.String setFileDescription(java.lang.String login, java.lang.String password, long fileId, java.lang.String title, java.lang.String tags, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll)  
 
Sets file title, tags and description for dedicated file or account as a whole
 
Sets file title, tags and description for dedicated file or account as a whole
  
== signup ==
+
=== signup ===
 
java.lang.String signup(java.lang.String login, java.lang.String password)  
 
java.lang.String signup(java.lang.String login, java.lang.String password)  
 
Creates new User with specified login(email) and password and sends confirmation email.
 
Creates new User with specified login(email) and password and sends confirmation email.
  
== signupUsername ==
+
=== signupUsername ===
 
java.lang.String signupUsername(java.lang.String login, java.lang.String password, java.lang.String username)  
 
java.lang.String signupUsername(java.lang.String login, java.lang.String password, java.lang.String username)  
 
Creates new User with specified login(email), short username for easing login and password and sends confirmation email.
 
Creates new User with specified login(email), short username for easing login and password and sends confirmation email.
  
== uploadCancelFile ==
+
=== uploadCancelFile ===
 
void uploadCancelFile(java.lang.String login, java.lang.String password, long fileId)  
 
void uploadCancelFile(java.lang.String login, java.lang.String password, long fileId)  
 
Call if upload was canceled
 
Call if upload was canceled
  
== uploadFinishFile ==
+
=== uploadFinishFile ===
 
java.lang.String uploadFinishFile(java.lang.String login, java.lang.String password, long fileId, java.lang.String md5)  
 
java.lang.String uploadFinishFile(java.lang.String login, java.lang.String password, long fileId, java.lang.String md5)  
 
Complete resumable upload
 
Complete resumable upload
  
== uploadStartedFileExists ==
+
=== uploadStartedFileExists ===
 
boolean uploadStartedFileExists(java.lang.String login, java.lang.String password, long fileId)  
 
boolean uploadStartedFileExists(java.lang.String login, java.lang.String password, long fileId)  
 
Checks if file was partially uploaded
 
Checks if file was partially uploaded
  
== uploadStartFile ==
+
=== uploadStartFile ===
 
long uploadStartFile(java.lang.String login, java.lang.String password, long dirID, java.lang.String name, long fullSize)
 
long uploadStartFile(java.lang.String login, java.lang.String password, long dirID, java.lang.String name, long fullSize)
 
Resumable upload - start
 
Resumable upload - start
  
== uploadStartFileUpdate ==
+
=== uploadStartFileUpdate ===
 
long uploadStartFileUpdate(java.lang.String login, java.lang.String password, long updateFileId, java.lang.String name, long fullSize)  
 
long uploadStartFileUpdate(java.lang.String login, java.lang.String password, long updateFileId, java.lang.String name, long fullSize)  
 
Update file
 
Update file
 
  
 
== '''Method Detail''' ==
 
== '''Method Detail''' ==
  
  
== Upload HOW TO ==
+
=== Upload HOW TO ===
  
First of all you should check if you have enough free space in user’s account:
+
First of all you should check if you have '''enough free space in user’s account''':
 
   function long getFreeSpace(String login, String password);
 
   function long getFreeSpace(String login, String password);
 
(returned value – free space in bytes)
 
(returned value – free space in bytes)
  
And what is upload limit for user (per file):
+
And what is '''upload limit for user''' (per file):
 
   function long getMaxFileSize(String login, String password);
 
   function long getMaxFileSize(String login, String password);
 
(returned value – maximum file size in bytes)
 
(returned value – maximum file size in bytes)
  
Please, check if target file corresponds the mentioned conditions, if it does, then:
+
Please, check if t'''arget file corresponds the mentioned conditions''', if it does, then:
  
Get session:  
+
'''Get session:'''
 
  function String createUploadSessionKey(String login, String password, long dirID);
 
  function String createUploadSessionKey(String login, String password, long dirID);
  
Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory. Or read full API description to learn how to browse user's directory for subdirectories' ids. Return session key if everything is ok and empty or null string if you can't upload to the specified dir.  
+
Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory.  
  
Get datacenter:
+
Or read full API description to learn how to browse user's directory for subdirectories' ids.
 +
 
 +
Return session key if everything is ok and empty or null string if you can't upload to the specified dir.
 +
 
 +
'''Get datacenter:'''
 
   function int getNewFileDataCenter(String login, String password);
 
   function int getNewFileDataCenter(String login, String password);
 +
 
If returned datacenter is less or equal then 0 - something goes wrong.
 
If returned datacenter is less or equal then 0 - something goes wrong.
  
Then get URL for upload using session and datacenter:
+
Then '''get URL for upload''' using session and datacenter:
 +
 
 
   function String getUploadFormUrl(int dataCenterID, String sessionKey);
 
   function String getUploadFormUrl(int dataCenterID, String sessionKey);
 +
 
Returned string is only valid if it starts with http, otherwise, you can't upload file;  
 
Returned string is only valid if it starts with http, otherwise, you can't upload file;  
  
To reserve fileId for yor upload call function:
+
'''To reserve fileId for yor upload call function''':
 +
 
 
   function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);
 
   function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);
 +
 
Again, fileId can be only positive.
 
Again, fileId can be only positive.
  
Then use received URL and fileId to upload by executing POST query multipart/form-data with fields
+
Then '''use received URL and fileId to upload by executing POST query multipart/form-data with fields'''
 
   
 
   
 
1) resumableFileId (file ID received via previous method)  
 
1) resumableFileId (file ID received via previous method)  
Line 1,404: Line 1,451:
 
2) resumableFirstByte (index of the first byte of current part. If the file is uploaded as single unit – then pass 0. If the file is divided into parts and is uploaded by parts – then pass index of the byte every part starts from)
 
2) resumableFirstByte (index of the first byte of current part. If the file is uploaded as single unit – then pass 0. If the file is divided into parts and is uploaded by parts – then pass index of the byte every part starts from)
  
Attach the file to the query as a parameter FilePart.
+
'''Attach the file to the query''' as a parameter FilePart.
 
   
 
   
 
where last parameter is file md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – you will get an error message. If the file was uploaded by parts, this function unites them into one.  
 
where last parameter is file md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – you will get an error message. If the file was uploaded by parts, this function unites them into one.  
  
You are done!  
+
'''You are done!'''
  
 
+
=== Search files on 4shared ===
== Search files on 4shared ==
+
  
 
To search files on 4shared.com you should use the following url
 
To search files on 4shared.com you should use the following url
Line 1,421: Line 1,467:
 
Example: q=funny cats
 
Example: q=funny cats
  
         searchExtention - type of file (extension or category)
+
         searchExtention - type of file (extension)
 +
       
 +
        searchCategory - category
 
          
 
          
 
If you need extension just use searchExtention=mid.  
 
If you need extension just use searchExtention=mid.  
Line 1,427: Line 1,475:
  
  
For searching in direct category use the following:
+
'''For searching in category use the following:'''
  
         category:1 - music
+
         searchCategory=music/audio
         category:2 - video
+
         searchCategory=video
         category:3 - photo
+
         searchCategory=photo
         category:4 - archive
+
         searchCategory=archive
         category:6 - program
+
         searchCategory=office/books_office/document/books
         category:7 - web documents
+
        searchCategory=program
         category:8 - mobile applications
+
         searchCategory=web  
          
+
         searchCategory=mobile/mobile_palm
Example: use searchExtention=category:1 - if you are searching only music.
+
         searchCategory=game
 +
 
 +
'''Example:''' use searchCategory=audio - if you are searching only for music.
 +
 
 +
Remember, if you are using parameter searchCategory you should also use searchmode=3
  
 
         sortType - type of sorting
 
         sortType - type of sorting
Line 1,452: Line 1,504:
  
  
Usage example:
+
'''Usage example:'''
 +
 
 
  http://search.4shared.com/network/searchXml.jsp?q=somebody&searchExtention=mid&sortType=3&sortOrder=1&searchmode=3&start=10
 
  http://search.4shared.com/network/searchXml.jsp?q=somebody&searchExtention=mid&sortType=3&sortOrder=1&searchmode=3&start=10
  
Response:
+
'''Response:'''
 +
 
 
  <search-result>
 
  <search-result>
 
  <query>somebody</query> - keyword
 
  <query>somebody</query> - keyword
Line 1,483: Line 1,537:
 
  </search-result>
 
  </search-result>
  
 
+
=== checkSharedDirAccess ===
 
+
 
+
 
+
 
+
 
+
== checkSharedDirAccess ==
+
  
 
   public int checkSharedDirAccess(java.lang.String login,
 
   public int checkSharedDirAccess(java.lang.String login,
Line 1,499: Line 1,547:
 
Checks if directory can be accessed by specified user with specified passwords
 
Checks if directory can be accessed by specified user with specified passwords
  
Parameters:
+
'''Parameters:'''
 +
 
 
         login - is user login
 
         login - is user login
 
         password - is user password
 
         password - is user password
Line 1,505: Line 1,554:
 
         dirPassword - generated password to view contents of not owned folders
 
         dirPassword - generated password to view contents of not owned folders
 
         userDirPassword - user specified password  
 
         userDirPassword - user specified password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
  Status.
 
  Status.
 
  0 ok
 
  0 ok
Line 1,516: Line 1,567:
 
  8 incorrect userDirPassword
 
  8 incorrect userDirPassword
  
== checkSubdomain ==
+
=== checkSubdomain ===
 +
 
  
 
   public java.lang.String checkSubdomain(java.lang.String login,
 
   public java.lang.String checkSubdomain(java.lang.String login,
Line 1,525: Line 1,577:
 
Checks if subdomain can be set for specified folder
 
Checks if subdomain can be set for specified folder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirId - id of the directory
 
   dirId - id of the directory
 
   subdomainName - name to be set  
 
   subdomainName - name to be set  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Empty string or null if everything is ok and error message otherwise
 
   Empty string or null if everything is ok and error message otherwise
  
== createNewFolder ==
+
=== createNewFolder ===
  
 
   public long createNewFolder(java.lang.String login,
 
   public long createNewFolder(java.lang.String login,
Line 1,542: Line 1,597:
 
Creates new folder as dirId subfolder
 
Creates new folder as dirId subfolder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of the directory to create folder in
 
   dirID - id of the directory to create folder in
 
   folderName - new folder name  
 
   folderName - new folder name  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   0 - if creation denied, newly created dir ID otherwise  
 
   0 - if creation denied, newly created dir ID otherwise  
 
   -1 - already exists  
 
   -1 - already exists  
 
   -2 - attempt to create folder in removed parent
 
   -2 - attempt to create folder in removed parent
  
== createUploadSessionKey ==
+
=== createUploadSessionKey ===
  
 
   public java.lang.String createUploadSessionKey(java.lang.String login,
 
   public java.lang.String createUploadSessionKey(java.lang.String login,
Line 1,560: Line 1,618:
 
Creates session key for uploading file
 
Creates session key for uploading file
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of the directory to upload to  
 
   dirID - id of the directory to upload to  
Returns:
+
'''Returns:'''
 +
 
 
   session key
 
   session key
  
== deleteFile ==
+
=== deleteFile ===
  
 
   public void deleteFile(java.lang.String login,
 
   public void deleteFile(java.lang.String login,
Line 1,575: Line 1,635:
 
Removes file to recycle bin or from recycle bin if it is already there
 
Removes file to recycle bin or from recycle bin if it is already there
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileID - id of the file to be removed
 
   fileID - id of the file to be removed
  
== deleteFolder ==
+
=== deleteFolder ===
  
 
   public void deleteFolder(java.lang.String login,
 
   public void deleteFolder(java.lang.String login,
Line 1,588: Line 1,649:
 
Completely removes folder and puts all of it contents to recycle bin
 
Completely removes folder and puts all of it contents to recycle bin
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of the directory to be removed
 
   dirID - id of the directory to be removed
  
== downloadFinished ==
+
=== downloadFinished ===
  
 
   public void downloadFinished(java.lang.String login,
 
   public void downloadFinished(java.lang.String login,
Line 1,601: Line 1,663:
 
Have to be called after full file download
 
Have to be called after full file download
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileId - id of the file which was downloaded
 
   fileId - id of the file which was downloaded
  
== getAllFolders ==
+
=== getAllFolders ===
  
 
   public com.pmstation.shared.soap.api.AccountItem[] getAllFolders(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem[] getAllFolders(java.lang.String login,
Line 1,613: Line 1,676:
 
Returns all of the folders in user's root directory
 
Returns all of the folders in user's root directory
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of info records about user's root folder subfolders
 
   Array of info records about user's root folder subfolders
  
== getAllItems ==
+
=== getAllItems ===
  
 
   public com.pmstation.shared.soap.api.AccountItem[] getAllItems(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem[] getAllItems(java.lang.String login,
Line 1,626: Line 1,692:
 
Returns info about all items in user's root folder
 
Returns info about all items in user's root folder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of info records about user's root folder content
 
   Array of info records about user's root folder content
  
== getCurrentUploaderVersion ==
+
=== getCurrentUploaderVersion ===
  
 
   public long getCurrentUploaderVersion()
 
   public long getCurrentUploaderVersion()
Line 1,638: Line 1,707:
 
Returns last uploader version. If this increase you should consider to look at online api documentation to check changes. We will try to maintain backward compatibility but this is not guaranteed.
 
Returns last uploader version. If this increase you should consider to look at online api documentation to check changes. We will try to maintain backward compatibility but this is not guaranteed.
  
Returns:
+
'''Returns:'''
 +
 
 
   Uploader version
 
   Uploader version
  
== getDirectLink ==
+
=== getDirectLink ===
  
 
   public java.lang.String getDirectLink(java.lang.String login,
 
   public java.lang.String getDirectLink(java.lang.String login,
Line 1,649: Line 1,719:
 
Returns link to start immediate downloading. Not always possible however, because we are ads-supported mostly. Returns link starting with "http" if ok.
 
Returns link to start immediate downloading. Not always possible however, because we are ads-supported mostly. Returns link starting with "http" if ok.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   link - indirect download link
 
   link - indirect download link
  
== getDirInfo ==
+
=== getDirInfo ===
  
 
   public com.pmstation.shared.soap.api.AccountItem getDirInfo(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem getDirInfo(java.lang.String login,
Line 1,662: Line 1,733:
 
Return info about specified folder
 
Return info about specified folder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of the folder  
 
   dirID - id of the folder  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   folder info
 
   folder info
  
== getFileDownloadLink ==
+
=== getFileDownloadLink ===
  
 
   public java.lang.String getFileDownloadLink(java.lang.String login,
 
   public java.lang.String getFileDownloadLink(java.lang.String login,
Line 1,677: Line 1,751:
 
Returns download link for user owned file
 
Returns download link for user owned file
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileID - id of file to be downloaded  
 
   fileID - id of file to be downloaded  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Download link or empty string if some errors occurs.
 
   Download link or empty string if some errors occurs.
  
== getFileInfo ==
+
=== getFileInfo ===
  
 
   public com.pmstation.shared.soap.api.AccountItem getFileInfo(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem getFileInfo(java.lang.String login,
Line 1,692: Line 1,769:
 
Returns info about file
 
Returns info about file
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileID - id of file to get info about  
 
   fileID - id of file to get info about  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   file info
 
   file info
  
== getFolderSharingProperties ==
+
=== getFolderSharingProperties ===
  
 
   public com.pmstation.shared.soap.api.SharedFolderProperties[] getFolderSharingProperties(java.lang.String login,
 
   public com.pmstation.shared.soap.api.SharedFolderProperties[] getFolderSharingProperties(java.lang.String login,
Line 1,707: Line 1,787:
 
Returns folder sharing properties. Output is two element array: res[0] - actual values. res[1] - properties which can be set for this user is marked as true.
 
Returns folder sharing properties. Output is two element array: res[0] - actual values. res[1] - properties which can be set for this user is marked as true.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
   dirId - id of the folder to properties for  
+
   dirId - id of the folder to properties for
Returns:
+
 +
'''Returns:'''
 +
 
 
   folder sharing properties
 
   folder sharing properties
  
== getFreeSpace ==
+
=== getFreeSpace ===
  
 
   public long getFreeSpace(java.lang.String login,
 
   public long getFreeSpace(java.lang.String login,
Line 1,721: Line 1,804:
 
Gets free space left for user
 
Gets free space left for user
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   free space left for user in bytes
 
   free space left for user in bytes
  
== getHistory ==
+
=== getHistory ===
  
 
   public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistory(java.lang.String login,
 
   public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistory(java.lang.String login,
Line 1,735: Line 1,821:
 
Returns history of operations in specified folder and subfolders. For operation field meanings see getOperationDescriptions()
 
Returns history of operations in specified folder and subfolders. For operation field meanings see getOperationDescriptions()
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirId - id of folder  
 
   dirId - id of folder  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of folder changes. May be null or empty
 
   Array of folder changes. May be null or empty
  
== getHistoryFromId ==
+
=== getHistoryFromId ===
  
 
   public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistoryFromId(java.lang.String login,
 
   public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistoryFromId(java.lang.String login,
Line 1,751: Line 1,840:
 
Returns history of operations which occurs in specified folder and subfolders with history id more then specified. For operation field meanings see getOperationDescriptions()
 
Returns history of operations which occurs in specified folder and subfolders with history id more then specified. For operation field meanings see getOperationDescriptions()
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirId - id of folder to take history for
 
   dirId - id of folder to take history for
 
   fromId - id floor of history  
 
   fromId - id floor of history  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of folder changes. May be null or empty
 
   Array of folder changes. May be null or empty
  
== getItemInfo ==
+
=== getItemInfo ===
  
 
   public com.pmstation.shared.soap.api.AccountItem getItemInfo(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem getItemInfo(java.lang.String login,
Line 1,768: Line 1,860:
 
Common method for getFileInfo(String, String, long) and getDirInfo(String, String, long) distinguished by value of dir parameter
 
Common method for getFileInfo(String, String, long) and getDirInfo(String, String, long) distinguished by value of dir parameter
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   itemID - id of element
 
   itemID - id of element
 
   dir - if true then supplied Id is folder and file otherwise  
 
   dir - if true then supplied Id is folder and file otherwise  
Returns:
 
  
== getItems ==
+
'''Returns:'''
 +
 
 +
=== getItems ===
  
 
   public com.pmstation.shared.soap.api.AccountItem[] getItems(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem[] getItems(java.lang.String login,
Line 1,783: Line 1,877:
 
Returns array of infos about contents of specified dir.
 
Returns array of infos about contents of specified dir.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of folder to list (-1 for root)
 
   dirID - id of folder to list (-1 for root)
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of info items
 
   Array of info items
  
== getMaxFileSize ==
+
=== getMaxFileSize ===
  
 
   public long getMaxFileSize(java.lang.String login,
 
   public long getMaxFileSize(java.lang.String login,
Line 1,797: Line 1,894:
 
Return maximum allowed file size for specified user
 
Return maximum allowed file size for specified user
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
   password - user password  
+
   password - user password
Returns:
+
 +
'''Returns:'''
 +
 
 
   maximum allowed file size in bytes
 
   maximum allowed file size in bytes
  
== getNewFileDataCenter ==
+
=== getNewFileDataCenter ===
  
 
   public long getNewFileDataCenter(java.lang.String login,
 
   public long getNewFileDataCenter(java.lang.String login,
Line 1,810: Line 1,910:
 
Returns datacenter id to upload files to
 
Returns datacenter id to upload files to
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   datacenter id to upload new files to
 
   datacenter id to upload new files to
  
== getNotOwnedSizeLimit ==
+
=== getNotOwnedSizeLimit ===
  
 
   public long getNotOwnedSizeLimit()
 
   public long getNotOwnedSizeLimit()
Line 1,822: Line 1,925:
 
Max file size which can be downloaded without speed limit
 
Max file size which can be downloaded without speed limit
  
Returns:
+
'''Returns:'''
 +
 
 
   max file size which can be downloaded without speed limit
 
   max file size which can be downloaded without speed limit
  
== getOperationDescriptions ==
+
=== getOperationDescriptions ===
  
 
public java.lang.String[] getOperationDescriptions()
 
public java.lang.String[] getOperationDescriptions()
Line 1,831: Line 1,935:
 
Returns array of OperationEnum names. Array index corresponds to values which can be returned as DirHistoryDTO.getOperation(). Array is supposed to be zero-based.
 
Returns array of OperationEnum names. Array index corresponds to values which can be returned as DirHistoryDTO.getOperation(). Array is supposed to be zero-based.
  
Returns:
+
'''Returns:'''
 +
 
 
   array of OperationEnum names
 
   array of OperationEnum names
  
== getRecycleBinItems ==
+
=== getRecycleBinItems ===
  
 
   public com.pmstation.shared.soap.api.AccountItem[] getRecycleBinItems(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem[] getRecycleBinItems(java.lang.String login,
Line 1,841: Line 1,946:
 
Returns info about files in recycle bin
 
Returns info about files in recycle bin
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Array of recycle bin content info items
 
   Array of recycle bin content info items
  
== getSharedDirItems ==
+
=== getSharedDirItems ===
  
 
   public com.pmstation.shared.soap.api.AccountItem[] getSharedDirItems(java.lang.String login,
 
   public com.pmstation.shared.soap.api.AccountItem[] getSharedDirItems(java.lang.String login,
Line 1,857: Line 1,965:
 
Return content of possibly not owned shared folder
 
Return content of possibly not owned shared folder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
Line 1,863: Line 1,972:
 
   dirPassword - 4shared generated dir password
 
   dirPassword - 4shared generated dir password
 
   userDirPassword - user set dir password if needed  
 
   userDirPassword - user set dir password if needed  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   content of specified shared folder or null
 
   content of specified shared folder or null
  
== getSpaceLimit ==
+
=== getSpaceLimit ===
  
 
   public long getSpaceLimit(java.lang.String login,
 
   public long getSpaceLimit(java.lang.String login,
Line 1,873: Line 1,984:
 
Returns user space limit
 
Returns user space limit
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   space limit
 
   space limit
  
== getUploadFormUrl ==
+
=== getUploadFormUrl ===
  
 
public java.lang.String getUploadFormUrl(int dataCenterID,
 
public java.lang.String getUploadFormUrl(int dataCenterID,
Line 1,886: Line 2,000:
 
Returns url to upload file to.
 
Returns url to upload file to.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   dataCenterID - id of datacenter to upload to
 
   dataCenterID - id of datacenter to upload to
 
   sessionKey - upload session key
 
   sessionKey - upload session key
  
== hasRightUpload ==
+
=== hasRightUpload ===
  
 
   public boolean hasRightUpload()
 
   public boolean hasRightUpload()
Line 1,896: Line 2,011:
 
Whether upload feature is on.
 
Whether upload feature is on.
  
Returns:
+
'''Returns:'''
 +
 
 
   whether upload feature is on.
 
   whether upload feature is on.
  
== isAccountActive ==
+
=== isAccountActive ===
  
 
   public boolean isAccountActive(java.lang.String login,
 
   public boolean isAccountActive(java.lang.String login,
Line 1,906: Line 2,022:
 
Checks account availability
 
Checks account availability
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   true if account is active
 
   true if account is active
  
== isAccountBanned ==
+
=== isAccountBanned ===
  
 
   public boolean isAccountBanned(java.lang.String login,
 
   public boolean isAccountBanned(java.lang.String login,
Line 1,919: Line 2,038:
 
Checks if user account is banned
 
Checks if user account is banned
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   true if user accont is banned
 
   true if user accont is banned
  
== isAccountPremium ==
+
=== isAccountPremium ===
  
 
   public boolean isAccountPremium(java.lang.String login,
 
   public boolean isAccountPremium(java.lang.String login,
Line 1,932: Line 2,054:
 
Checks if user account is premium
 
Checks if user account is premium
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   true of user has premium account
 
   true of user has premium account
  
== isExistsLoginPassword ==
+
=== isExistsLoginPassword ===
  
 
   public boolean isExistsLoginPassword(java.lang.String login,
 
   public boolean isExistsLoginPassword(java.lang.String login,
Line 1,945: Line 2,070:
 
true-false version of login
 
true-false version of login
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   true if login was successful
 
   true if login was successful
  
== login ==
+
=== login ===
  
 
   public java.lang.String login(java.lang.String login,
 
   public java.lang.String login(java.lang.String login,
Line 1,958: Line 2,086:
 
Login
 
Login
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password  
 
   password - user password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Empty string if all ok, diagnostic message otherwise
 
   Empty string if all ok, diagnostic message otherwise
  
== markSynchronized ==
+
=== markSynchronized ===
  
 
   public void markSynchronized(java.lang.String login,
 
   public void markSynchronized(java.lang.String login,
Line 1,972: Line 2,103:
 
Informs 4shared to write folder and subfolders usage history
 
Informs 4shared to write folder and subfolders usage history
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirId - id of folder to write history for
 
   dirId - id of folder to write history for
  
== pasteFilesDirs ==
+
=== pasteFilesDirs ===
  
 
   public java.lang.String pasteFilesDirs(java.lang.String login,
 
   public java.lang.String pasteFilesDirs(java.lang.String login,
Line 1,988: Line 2,120:
 
Copy-pastes or cut-pastes a group of files and dirs. Use this to copy or move a group of files to another directory.
 
Copy-pastes or cut-pastes a group of files and dirs. Use this to copy or move a group of files to another directory.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
Line 1,995: Line 2,128:
 
   fileIds - ids of file to be moved/copied
 
   fileIds - ids of file to be moved/copied
 
   dirIds - ids of folders to be moved/copied  
 
   dirIds - ids of folders to be moved/copied  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   diagnostic message or empty string if all ok
 
   diagnostic message or empty string if all ok
  
== renameFile ==
+
=== renameFile ===
  
 
   public long renameFile(java.lang.String login,
 
   public long renameFile(java.lang.String login,
Line 2,007: Line 2,142:
 
Renames specified file
 
Renames specified file
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
Line 2,017: Line 2,153:
 
   fileID if rename was successful
 
   fileID if rename was successful
  
== renameFolder ==
+
=== renameFolder ===
  
 
   public long renameFolder(java.lang.String login,
 
   public long renameFolder(java.lang.String login,
Line 2,026: Line 2,162:
 
Renames specified folder
 
Renames specified folder
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirID - id of folder to be renamed
 
   dirID - id of folder to be renamed
 
   newName - new name of folder  
 
   newName - new name of folder  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   -1 if file exists,  
 
   -1 if file exists,  
 
   0 in case of other failures,  
 
   0 in case of other failures,  
 
   dirID if rename was successful
 
   dirID if rename was successful
  
== restoreFile ==
+
=== restoreFile ===
  
 
   public void restoreFile(java.lang.String login,
 
   public void restoreFile(java.lang.String login,
Line 2,044: Line 2,183:
 
Restores file from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.
 
Restores file from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileID - id of file to be restored
 
   fileID - id of file to be restored
  
== restoreFiles ==
+
=== restoreFiles ===
  
 
   public void restoreFiles(java.lang.String login,
 
   public void restoreFiles(java.lang.String login,
Line 2,057: Line 2,197:
 
Restores group of files from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.
 
Restores group of files from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileIDs - Array of file ids to be restored
 
   fileIDs - Array of file ids to be restored
  
== setFolderSharingProperties ==
+
=== setFolderSharingProperties ===
  
 
   public java.lang.String setFolderSharingProperties(java.lang.String login,
 
   public java.lang.String setFolderSharingProperties(java.lang.String login,
Line 2,071: Line 2,212:
 
Sets folder sharing properties
 
Sets folder sharing properties
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   dirId - id of folder to set properties for
 
   dirId - id of folder to set properties for
 
   folderProperties - new properties values  
 
   folderProperties - new properties values  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   Diagnostic message or empty string if all is ok
 
   Diagnostic message or empty string if all is ok
  
== signup ==
+
=== signup ===
  
 
   public java.lang.String signup(java.lang.String login,
 
   public java.lang.String signup(java.lang.String login,
Line 2,086: Line 2,230:
 
Creates new User and sends confirmation email.
 
Creates new User and sends confirmation email.
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - desired login
 
   login - desired login
 
   password - password  
 
   password - password  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   error message if any. Empty string if all ok.
 
   error message if any. Empty string if all ok.
  
== syncFinished ==
+
=== syncFinished ===
  
 
   public void syncFinished(java.lang.String login,
 
   public void syncFinished(java.lang.String login,
Line 2,100: Line 2,247:
 
Should be called in the end of each sync operation
 
Should be called in the end of each sync operation
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileId - which file was synced. -1 if not applicable
 
   fileId - which file was synced. -1 if not applicable
  
== uploadCancelFile ==
+
=== uploadCancelFile ===
  
 
   public void uploadCancelFile(java.lang.String login,
 
   public void uploadCancelFile(java.lang.String login,
Line 2,113: Line 2,261:
 
Call if upload was canceled
 
Call if upload was canceled
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileId - id of file which upload is canceling
 
   fileId - id of file which upload is canceling
  
== uploadFinishFile ==
+
=== uploadFinishFile ===
  
 
   public java.lang.String uploadFinishFile(java.lang.String login,
 
   public java.lang.String uploadFinishFile(java.lang.String login,
Line 2,127: Line 2,276:
 
Complete resumable upload
 
Complete resumable upload
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileId - returned from initial call to uploadStartFile() - existing file in 'being uploaded by parts' state
 
   fileId - returned from initial call to uploadStartFile() - existing file in 'being uploaded by parts' state
 
   md5 - original file MD5 to verify file consistency at server side  
 
   md5 - original file MD5 to verify file consistency at server side  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   empty string if success or error message
 
   empty string if success or error message
  
== uploadStartedFileExists ==
+
=== uploadStartedFileExists ===
  
 
   public boolean uploadStartedFileExists(java.lang.String login,
 
   public boolean uploadStartedFileExists(java.lang.String login,
Line 2,143: Line 2,295:
 
Checks if file was partially uploaded
 
Checks if file was partially uploaded
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
 
   fileId - id of file to be checked  
 
   fileId - id of file to be checked  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   true if there is part of file already uploaded.
 
   true if there is part of file already uploaded.
  
== uploadStartFile ==
+
=== uploadStartFile ===
  
 
   public long uploadStartFile(java.lang.String login,
 
   public long uploadStartFile(java.lang.String login,
Line 2,160: Line 2,315:
 
Resumable upload - start
 
Resumable upload - start
  
Parameters:
+
'''Parameters:'''
 +
 
 
   dirID - (-1) means upload to user's root dir  
 
   dirID - (-1) means upload to user's root dir  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   fileId to pass as parameter in all subsequent partial uploads
 
   fileId to pass as parameter in all subsequent partial uploads
  
== uploadStartFileUpdate ==
+
=== uploadStartFileUpdate ===
  
 
   public long uploadStartFileUpdate(java.lang.String login,
 
   public long uploadStartFileUpdate(java.lang.String login,
Line 2,175: Line 2,333:
 
Update file
 
Update file
  
Parameters:
+
'''Parameters:'''
 +
 
 
   login - user login
 
   login - user login
 
   password - user password
 
   password - user password
Line 2,181: Line 2,340:
 
   name - empty string means don't change existing name
 
   name - empty string means don't change existing name
 
   fullSize -  
 
   fullSize -  
Returns:
+
 
 +
'''Returns:'''
 +
 
 
   id of temporary file uploading of which will cause update of original file
 
   id of temporary file uploading of which will cause update of original file

Latest revision as of 10:42, 31 October 2011

Welcome to 4shared SOAP API documentation!

Dear developer!

We are glad to introduce you official 4shared API Program. With the 4shared API, you can get started developing your application for Mobile Phones (iPhone, Android, Symbian, Blackberry, Windows mobile), Windows, Mac, iPad, and Linux today.

You may easily use more than 50 API functions to perform any actions with 4shared like - access web account, upload\download files, search files, create and delete folders, etc.

4shared API is totaly free! All required samples you may find at 4shared API documentation. Any questions regarding 4shared developer program you may discuss at our forum.

Every month we will pick best app with 4shared API (the more inserted key 4shared functions, the better) and award developer for $5,000! We pay $5,000/month for best app.

Contents

Sources

4shared Project at google code.google.com

WSDL can be obtained from here or please check here for more secure SOAPing.

You can browse java sources from mercurial repositories at http://code.google.com/p/4shared-api/source/browse/. Or use hg clone https://4shared-api.googlecode.com/hg/ 4shared-api to get local copy of sources.

Quick start guide

To start working with 4shared SOAP API you should have a copy of mercurial for your favorite OS, Java SDK, ant building system. Some Java IDE is also recomended.

1. Get sources from google.code.com:

 hg clone https://4shared-api.googlecode.com/hg/ 4shared-api

2. Go to created folder and build project:

 ant

3. Try to use some of provided examples:

 cd dist/demo
 ./signup <username> <password>
 ./createfolder <username> <password> <foldername>
 ./upload <username> <password> <path to file>
 ./browse <login> <password>

4. Learn how this demos have been written. All demo sources are situated in demo/com/pmstation/shared/soap/demo

5. Write your own fresh and brilliant application

6. Important! You must include the following into the app:

Check the simple example:

let's have the user app_name_test have password 1,

where app_name - is the name of your application.

user enters his credentials as:

login: "app_name_test "

password: "1"

You should silently add designator for your to user provided password.

So, you will send:

login: "app_name_test "

password: "!!!app_name!!:1"

for any function, which needs password.

Samples

Java:

CreateFolderDemo.java

DeleteFileDemo.java

Demo.java

DownloadDemo.java

EnumerateItemsDemo.java

EnumerateItemsDemo2.java

LoginDemo.java

RecycleBinDemo.java

RenameDemo.java

SignupDemo.java

StringUtils.java

UploadDemo.java


iOS


Every application in iOS can use 4shared service. The client can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions. These functions may be used to request for the content of your account, get the necessary links to files, and edit the file structure and the directory properties on the server. The full description of the api is provided here (link to http://help.4shared.com/index.php/SOAP_API). The SOAP-protocol may be checked here (link to http://en.wikipedia.org/wiki/SOAP).

To call up 4shared api-function, it’s necessary to send the XML-message to server http://api.4shared.com/jax2/DesktopApp SOAP.

The common template for the message is the following:

|<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" <br>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Body>

		<function xmlns="http://api.soap.shared.pmstation.com/">
			<arg0 xmlns="">login</arg0>
			<arg1 xmlns="">password</arg1>
			<arg2 xmlns="">arg1</arg2>
			...
		</function>
	</soapenv:Body>
</soapenv:Envelope>" ,where “function” is the name of the called function.

Having indicated the function, one should enlist its arguments. There’re only 2 arguments in almost all 4shared api-functions – these are login and password.

In response to the call, 4shared server will return the results of the function, the SOAP-message in XML-format:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
	<S:Body>
		<ns2:functionResponse xmlns:ns2="http://api.soap.shared.pmstation.com/">
			<return>
				result
			</return>
		</ns2: functionResponse>
	</S:Body>
</S:Envelope> , where “result” is the result of calling up the “function”.

As an example, we need to get the content of the directory. To do this, we need to call the function “getItems” (link to http://help.4shared.com/index.php/SOAP_API#getItems).

Its first 2 arguments are, as usual, login and password. The 3rd one is the ID of the requested directory.

The body of the relative SOAP-message will be as follows:

<getItems xmlns="http://api.soap.shared.pmstation.com/">
	<arg0 xmlns="">username@server.com</arg0>
	<arg1 xmlns="">*********</arg1>
	<arg2 xmlns="">123456789</arg2>
</getItems>

In response, 4shared server will return the array with the elements of directory:

<item>
	<date>(date of file creation)</date>
	<directory>(true – if file is a directory, otherwise - false)</directory>
	<downloadCount>(the number of file downloads)</downloadCount>
	<downloadLink>(link for the file-download from 4shared-server)</downloadLink>
	<id>(file ID)</id>
	<md5>(md5-hash)</md5>
	<name>(name)</name>
	<parentId>(parent directory ID)</parentId>
	<size>(size)</size>
	…
</item>

Let’s consider the example of the simple application, which allows the user to browse the content of his/her account.

The 1st thing, which should be done, when starting the program, is to authorize (login) on 4shared server by means of calling up the function “login” (link to http://help.4shared.com/index.php/SOAP_API#login ).

If authorization is passed successfully, the next step will be the request for the root account directory by means of calling up the function “getRoot” (link to http://help.4shared.com/index.php/SOAP_API#getRoot). The calling result will be the structure “item”, described above.

To store received information, I’ve created subclass File:

@interface File : NSObject
{
	NSUInteger _id;
	NSUInteger _parentId;
	NSString *_name;
	NSUInteger _size;
	NSString *_link;
	BOOL _dir;
    
	NSArray *_content;
}

…

@end

Now that we have the root directory ID, we can use the function “getItems”, to get its content, and then the content of any subdirectory.

To create the XML-formatted message and the parsing of received result, it’s possible to use any XML – parser. In the demo-sample, I’ve used GDataXML-parser from Google Data APIs Objective-C Client Library http://code.google.com/p/gdata-objectivec-client/).

The function to generate the message may be as follows:

+ (NSURLRequest*)soapRequestWithFunction:(NSString*)function andParams:(NSArray*)params
{
   	GDataXMLElement *xmlFunction = [GDataXMLNode elementWithName:function];
	GDataXMLNode *xmlNS = [GDataXMLNode namespaceWithName:nil stringValue:@"http://api.soap.shared.pmstation.com/"];
	[xmlFunction addNamespace:xmlNS];
	
	for (NSUInteger i = 0; i < [params count]; i++)
	{
		NSString *elementName = [NSString stringWithFormat:@"arg%lu", i];
		GDataXMLElement *arg = [GDataXMLNode elementWithName:elementName];
		NSString *param = (NSString*)[params objectAtIndex:i];
		[arg setStringValue:(NSString*) param];
		GDataXMLNode *attrib = [GDataXMLNode attributeWithName:@"xmlns" stringValue:@""];
		[arg addAttribute:attrib];
		[xmlFunction addChild:arg];
	}
    
	GDataXMLElement *body = [GDataXMLNode elementWithName:@"soapenv:Body"];
	[body addChild:xmlFunction];
	
	GDataXMLElement *soapEnvelope = [GDataXMLNode elementWithName:@"soapenv:Envelope"];
	GDataXMLNode *soapNS1 = [GDataXMLNode namespaceWithName:@"soapenv" stringValue:@"http://schemas.xmlsoap.org/soap/envelope/"];
	GDataXMLNode *soapNS2 = [GDataXMLNode namespaceWithName:@"xsd" stringValue:@"http://www.w3.org/2001/XMLSchema"];
	GDataXMLNode *soapNS3 = [GDataXMLNode namespaceWithName:@"xsi" stringValue:@"http://www.w3.org/2001/XMLSchema-instance"];
	[soapEnvelope setNamespaces:[NSArray arrayWithObjects:soapNS1, soapNS2, soapNS3, nil]];
	[soapEnvelope addChild:body];
	
	GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithRootElement:soapEnvelope];
	[doc setVersion:@"1.0"];
	[doc setCharacterEncoding:@"UTF-8"];
	NSData *data = [doc XMLData];
	[doc release];
	NSString *dataLen = [NSString stringWithFormat:@"%lu", [data length]];
	
	NSURL *url = [NSURL URLWithString:@"http://api.4shared.com/jax2/DesktopApp"];
	NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
	[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[request addValue:@"" forHTTPHeaderField:@"SOAPAction"];
	[request addValue:dataLen forHTTPHeaderField:@"Content-Length"];
	[request setHTTPMethod:@"POST"];
	[request setHTTPBody: data];
	
	return request;
}

The content of the directory is shown in the table (class FilesViewController). I show its name and size in the cell, related to the file accordingly:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	…
	cell.accessoryType = file.isDir ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
	cell.imageView.image = file.isDir ? [UIImage imageNamed:@"dir.png"] : nil;
	cell.textLabel.text = file.name;
	cell.detailTextLabel.text = file.isFile ? [NSString stringWithFormat:@"%.2f Kb", (CGFloat) file.size / 1024.0] : nil;
	…
}

All content is opened via tap in the cell with directory. The page with the following link is opened in the browser via tap on the file:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	…
	if (file.isDir)
	{
		FilesViewController *fvc = [[FilesViewController alloc] initWithFile:file];
	        [self.navigationController pushViewController:fvc animated:YES];
        	[fvc release];
	}
	else
	{
        	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:file.link]];
	}
	…
}

The demo-sample can be downloaded here (http://dc243.4shared.com/download/ecV5Tw4I/ios_samples.zip).

To start the sample application, enter demo-Prefix.pch in the file, enter your login and password from the site 4shared (macros LOGIN and PASSWORD).


Symbian (QT)


Every application can interact with 4shared server via SOAP protocol, by means of calling up 4shared API functions.

These functions may be used to request for the content of your account, get the necessary links to files, and edit the file structure and the directory properties on the server.

The full description of the api is provided here (link to http://help.4shared.com/index.php/SOAP_API).

The SOAP-protocol may be checked here (link to http://en.wikipedia.org/wiki/SOAP).

As an SDK for creating applications for mobile devices, let’s take "Nokia Qt SDK 1.0", which can be got here (http://www.forum.nokia.com/Develop/Qt/). This package also includes IDE "Qt Creator", which we will use.

In the beginning, let’s create the new project with type “Mobile application Qt” and name it 4shared. In the visual editor we’ll add “List widget” in the main window, which will include the elements of the root catalogue, downloaded from 4shared server. In the class MainWindow constructor, in a line

- setCentralWidget(ui->listWidget); - stretch listWidget to the full screen.


To work with SOAP protocol in a more convenient way, we’ll take initial codes from the library QtSOAP and insert them into the project, as this library isn’t included into mobile version.

In addition to that, in order to make the application work with network in Symbian devices, it’s necessary to add the following line in the file 4shared.pro in the part, devoted to the specific Symbian settings:

-
Symbian {
	...
	TARGET.CAPABILITY += NetworkServices
	...
}
-

Then, we’ll add and initialize members in class MainWindow':

-
class MainWindow : public QMainWindow
{
	...
    QNetworkAccessManager nam;
    QtSoapHttpTransport http;
	...
};

MainWindow::MainWindow(QWidget *parent) :
	...
    nam(this),
    http(this),
	...
{
	...
    connect(&http, SIGNAL(responseReady()), SLOT(getResponse()));

    http.setNetworkAccessManager(&nam);
    http.setAction("");
    http.setHost("api.4shared.com", 80);
	...
}
-
,which realize (implement) the transfer of our future requests. 

The slot getResponse() will be invoked, when the answers to our requests are received.


To download the list of files and subdirectories of the root directory, it’s necessary to perform 3 requests in series:

1. isExistsLoginPassword - authentication

2. getRoot – receipt of information about the root directory

3. getItems – receipt of the list of elements in the defined directory (in our case – root directory )

-
class MainWindow : public QMainWindow
{
	...
private slots:
    void getResponse();

private:
    QtSoapMessage initStdSoapMessage(const QString &methodName);

    void authorize();
    void authorizeHandler(const QtSoapType &res);

    void getRoot();
    void getRootHandler(const QtSoapType &res);

    void getItems(long id);
    void getItemsHandler(const QtSoapType &res);

    enum Operation {unknown, authorize_op, getRoot_op, getItems_op};

private:
	...

    Operation operation;

    QString login, password;

    long rootId;
};

void MainWindow::getResponse()
{
    Operation op = operation;
    operation = unknown;

    // Get the response, check for error.
    const QtSoapMessage &resp = http.getResponse();
    if(resp.isFault()) {
        QMessageBox::warning(NULL, "Warning", "SOAP: query failed (" + resp.faultString().value().toString() + ")");
        return;
    }

    // Extract the return value from this method response, check for errors.
    const QtSoapType &res = resp.returnValue();
    if(!res.isValid()) {
        QMessageBox::warning(NULL, "Warning", "SOAP: invalid return value");
        return;
    }

    switch(op)
    {
    case authorize_op:
        authorizeHandler(res);
        break;
    case getRoot_op:
        getRootHandler(res);
        break;
    case getItems_op:
        getItemsHandler(res);
        break;
    case unknown:
        break;
    }
}

QtSoapMessage MainWindow::initStdSoapMessage(const QString &methodName)
{
    QtSoapMessage request;
    request.setMethod(QtSoapQName(methodName, "http://api.soap.shared.pmstation.com/"));
    request.addMethodArgument("arg0", "", login);
    request.addMethodArgument("arg1", "", password);
    return request;
}

void MainWindow::authorize()
{
    QtSoapMessage request = initStdSoapMessage("isExistsLoginPassword");
    operation = authorize_op;
    http.submitRequest(request, "/jax2/DesktopApp");
}

void MainWindow::authorizeHandler(const QtSoapType &res)
{
    bool auth = res.value().toBool();
    if(auth)
    {
       // QMessageBox::information(NULL, "Authorization", "Authorized");
        getRoot();
    }
    else
        QMessageBox::warning(NULL, "Warning", "Invalid user name or password");
}

void MainWindow::getRoot()
{
    QtSoapMessage request = initStdSoapMessage("getRoot");
    operation = getRoot_op;
    http.submitRequest(request, "/jax2/DesktopApp");
}

void MainWindow::getRootHandler(const QtSoapType &res)
{
    rootId = res["id"].toInt();
    getItems(rootId);
}

void MainWindow::getItems(long id)
{
    QtSoapMessage request = initStdSoapMessage("getItems");
    request.addMethodArgument("arg2", "", id);
    operation = getItems_op;
    http.submitRequest(request, "/jax2/DesktopApp");
}

void MainWindow::getItemsHandler(const QtSoapType &res)
{
    for(int i=0; i<res.count(); i++)
    {
        const QtSoapType &item = res[i];

        if(item["removed"].toBool())
            continue;

        QString name;
        if(item["directory"].toBool())
            name = " <dir> ";
        name += item["name"].toString();

        QListWidgetItem *itm = new QListWidgetItem(name);
        itm->setSizeHint(QSize(0, 50));
        ui->listWidget->addItem(itm);
    }
}
-

Demo-sample can be downloaded here (http://dc243.4shared.com/download/bFbwuFVS/symbian_Qt_example.zip).

To start the sample application, insert your login and password from 4shared in the file MainWindow.cpp (variable login and password).


Android



1. 4shared API.


Service 4shared is a usual web-service, WSDL description of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.

You can read more about web-services and WSDL' here: http://ru.wikipedia.org/wiki/%D0%92%D0%B5%D0%B1-%D1%81%D0%BB%D1%83%D0%B6%D0%B1%D0%B0, http://ru.wikipedia.org/wiki/WSDL.

Short description of API functions can found here: http://help.4shared.com/index.php/SOAP_API.

To work with SOAP API, you can use direct SOAP-calling, but it’s more convenient to use another library for request parsing. For instance, you can use free library: (http://code.google.com/p/ksoap2-android/).


2. Tools for Development.


Development of applications for Android is possible on any platform, which allows Andrid SDK setup. System requirements can be checked here: http://developer.android.com/sdk/requirements.html.

You can download Android SDK here: http://developer.android.com/sdk/index.html, setup instructions are available here: http://developer.android.com/sdk/installing.html.

The recommended environment for development is Eclipse (http://www.eclipse.org/downloads/) with the plugin for Android (http://developer.android.com/sdk/eclipse-adt.html). Any device with OS Android, or an emulator of the device, included into Android SDK, is suitable for starting the developed application.

Detailed instruction for beginners in app development can be found here: http://developer.android.com/guide/developing/index.html.


3. Step-by-Step Instruction.


Resource http://developer.android.com comprises all necessary information for developers.

The most essential (fundamental) notions are described in the article: http://developer.android.com/guide/topics/fundamentals.html.

Step-by-step instruction of the simple app for 4shared is displayed below.

1) Install a Platform (http://developer.android.com/resources/tutorials/hello-world.html)

2) Create an AVD (http://developer.android.com/resources/tutorials/hello-world.html)

3) Create a New Android Project (http://developer.android.com/resources/tutorials/hello-world.html)

Image1.png

4) To insert changes, needed to make the minimum 4shared-application work

To link the ksoap2 library to the project, it’s necessary to create subcatalog libs in the catalogue Hello4shared and place jar-archive of this library there. Then, choose Project > Options in menu Eclipse, and after that select subsection Java Build Path and tab Libraries. Press the button Add JARs and display the path to the library.

Image2.png

With the help of menu File > New > Class, let’s create 2 subclasses: AccountItem, representing the user’s file or catalogue on 4shared server, and ForSharedService, with the help of which 4shared API remote methods are called up.

AccountItem is used to desereal data from the network and provides convenient methods to receive information about the file/catalogue, for example, getName() and getDownloadLink() return the filename and the download link accordingly.

    package com.example.hello4shared;

    import org.ksoap2.serialization.SoapPrimitive;

    /**
     * 4shared account item, representing a file or a directory description data.
     * Implementation includes network serialization functionality.
     */
    public class AccountItem {
	private long id;
	private String name;
	private boolean directory;

	public AccountItem() {
	}

	public long getId() {
	    return id;
	}

	public String getName() {
	    return name;
	}

	public boolean isDirectory() {
	    return directory;
	}

	public String toString() {
	    return directory ? "[" + name + "]" : name;
	}

	public void setProperty(String propName, Object value) {
	    if (value == null) {
		return;
	    }
	    if (value instanceof SoapPrimitive) {
		value = ((SoapPrimitive) value).toString();
	    }

	    if (propName.equals("id")) {
		if (value instanceof Long)
		    id = ((Long) value).longValue();
		else
		    id = Long.parseLong(value.toString());
	    }
	    if (propName.equals("directory")) {
		directory = convertBoolean(value);
	    }
	    else if (propName.equals("name")) {
		name = convertString(value);
	    }
	}

	private boolean convertBoolean(Object val) {
	    if (val == null)
		return false;

	    if (val.toString().toLowerCase().equals("true"))
		return true;
	    else
		return false;
	}

	private String convertString(Object str) {
	    if (!(str instanceof String))
		return null;

	    if (((String) str).equals("String{}"))
		return "";
	    else
		return (String) str;
	}
    }

ForSharedService is the interlayer for the convenient call of remote methods and hides the code of interaction with technology SOAP.

    package com.example.hello4shared;

    import org.ksoap2.SoapEnvelope;
    import org.ksoap2.serialization.PropertyInfo;
    import org.ksoap2.serialization.SoapObject;
    import org.ksoap2.serialization.SoapSerializationEnvelope;
    import org.ksoap2.transport.AndroidHttpTransport;
    import org.ksoap2.transport.Transport;

    import java.util.Hashtable;
    import java.util.Vector;

    /**
     * 4shared API local layer
     */
    public class ForSharedService {
	private String mUsername;
	private String mPassword;
	private static final String SERVICE_URL = "http://api.4shared.com/jax2/DesktopApp";
	private static final String SERVICE_NAMESPACE = "http://api.soap.shared.pmstation.com/";

	/**
	 * Constructs this object for an account
	 * @param username Username of the account
	 * @param password Password of the account
	 */
	public ForSharedService(String username, String password) {
	    mUsername = username;
	    mPassword = password;
	}

	/**
	 * Login with current account
	 */
	public void login() throws Exception {
	    String methodName = "login";
	    SoapObject rpc = getRpc(methodName);
	    SoapSerializationEnvelope envelope = getEnvelope(rpc);
	    Transport ht = getHttpTransport();

	    String result;

	    ht.call(SERVICE_URL + "/" + methodName, envelope);
	    result = (envelope.getResponse()).toString();

	    if (!isEmptyString(result))
		throw new Exception(result);
	}

	/**
	 * Get account's root folder
	 * @return Item representing the root directory
	 */
	public AccountItem getRoot() throws Exception {
	    String soapAction = SERVICE_URL + "/getRoot";

	    SoapObject rpc = getRpc("getRoot");
	    SoapSerializationEnvelope envelope = getEnvelope(rpc);
	    Transport ht = getHttpTransport();

	    ht.call(soapAction, envelope);
	    return getAccountItem((SoapObject) envelope.getResponse());
	}

	/**
	 * Get contents of a directory
	 * @param dirId Directory's identifier
	 * @return Array of items representing contents of the directory
	 */
	public AccountItem[] getItems(long dirId) throws Exception {
	    String methodName = "getItems";

	    SoapObject rpc = getRpc(methodName);
	    rpc.addProperty("arg2", new Long(dirId));
	    SoapSerializationEnvelope envelope = getEnvelope(rpc);

	    Transport ht = getHttpTransport();

	    ht.call(SERVICE_URL + "/" + methodName, envelope);
	    Object result = envelope.getResponse();

	    return getAccountItems(result);
	}

	private Transport getHttpTransport() {
	    Transport ht = new AndroidHttpTransport(SERVICE_URL);
	    ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	    ht.debug = true;

	    return ht;
	}

	private SoapObject getRpc(String methodName) {
	    SoapObject rpc = new SoapObject(SERVICE_NAMESPACE, methodName);
	    rpc.addProperty("arg0", mUsername);
	    rpc.addProperty("arg1", mPassword);

	    return rpc;
	}

	private SoapSerializationEnvelope getEnvelope(SoapObject rpc) {
	    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

	    envelope.bodyOut = rpc;
	    envelope.encodingStyle = SoapSerializationEnvelope.XSD;

	    return envelope;
	}

	private AccountItem getAccountItem(SoapObject item) {
	    return deserialize(new AccountItem(), item);
	}

	@SuppressWarnings("unchecked")
	private AccountItem[] getAccountItems(Object response) {
	    if (response == null)
		return null;

	    if (!(response instanceof SoapObject))
		return null;

	    Vector items = new Vector();

	    for (int i = 0; i < ((SoapObject) response).getPropertyCount(); i++) {
		Object item = ((SoapObject) response).getProperty(i);
		if (item instanceof SoapObject) {
		    items.addElement(deserialize(new AccountItem(), (SoapObject) item));
		}
	    }

	    AccountItem[] accountItems = new AccountItem[items.size()];
	    items.copyInto(accountItems);

	    return accountItems;
	}

	@SuppressWarnings( {
		"unchecked", "deprecation"
	})
	private AccountItem deserialize(AccountItem newItem, SoapObject item) {
	    Hashtable ht = new Hashtable();
	    PropertyInfo propInfo = new PropertyInfo();
	    for (int n = 0; n < item.getPropertyCount(); n++) {
		item.getPropertyInfo(n, ht, propInfo);
		newItem.setProperty(propInfo.name, item.getProperty(n));
	    }

	    return newItem;
	}

	private static boolean isEmptyString(String string) {
	    return (string == null || string.equals("")
		   || string.toLowerCase().equals("string{}")
		   || string.toLowerCase().equals("anytype{}"));
	}
    }

The classes SoapObject, SoapSerializationEnvelope, AndroidHttpTransport – are included into the library ksoap2.

SoapObject, SoapSerializationEnvelope serve to parse soap-requests, whereas AndroidHttpTransport provides transport to call up the requests.

The call up of the function itself is realized by the method call (), of the class AndroidHttpTransport.

The service’s answer can be received by means of calling up the method getResponse() of the class SoapSerializationEnvelope.

The functions, transferred to the service, are defined by calling up the method addProperty of the class SoapObject as a pair “parameter name - value”.

Let’s create a window (activity) to display the list of user’s files and catalogues from 4shared server.

To do that, let’s create the new class (File > New > Class), derivative from ListActivity, in Eclipse environment, and call it AccountContents.


Let’s edit AccountContents.java, by redefining the method onCreate, called up by means of initializing the window (activity).


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Use a ListAdapter that will map an array of account's root folder items to TextViews
        setListAdapter(new ArrayAdapter<AccountItem>(this,
                android.R.layout.simple_list_item_1, Hello4shared.rootContents));
    }

The class ArrayAdapter establishes accordance (correspondence) between the list elements of the user’s interface and the list of files and catalogues on 4shared server, which will be uploaded into the static variable rootContents of the class Hello4shared.

In the method onCreate of the main window (activity) of the application, the code of which is in the file Hello4shared.java, let’s create the elements of the user’s interface for insertion and transfer of the user’s name (login) and 4shared account password to the server.

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Prepare vertical linear layout
        LinearLayout mainLayout = new LinearLayout(this);
        mainLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        mainLayout.setOrientation(LinearLayout.VERTICAL);
        
        // Create views
        TextView loginView = new TextView(this);
        loginView.setText("login:");
        TextView passwordView = new TextView(this);
        passwordView.setText("password:");
        
        final EditText loginEdit = new EditText(this);
        final EditText passwordEdit = new EditText(this);
        passwordEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        
        Button loginButton = new Button(this);
        loginButton.setText("Submit");
        loginButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String username = loginEdit.getText().toString();
                String password = passwordEdit.getText().toString();
                
                // If username and password entered correctly
                if (username.length() != 0 && password.length() != 0) {
                    // Start login procedure
                    login(username, password);
                }
            }
        });
        
        // Add views to layout
        mainLayout.addView(loginView);
        mainLayout.addView(loginEdit);
        mainLayout.addView(passwordView);
        mainLayout.addView(passwordEdit);
        mainLayout.addView(loginButton);
        
        // Set the layout as activity main layout
        setContentView(mainLayout);
    }

The handler of the press-button loginButton checks the properness of inserted data and, if succeeds, calls up the method login (), which starts the process of checking the user’s data on 4shared server, and also requests the list of files and catalogues of the account root catalogue.


    private void login(final String username, final String password) {
        mProgressDialog = ProgressDialog.show(this, "", "Please wait...", true);
        mProgressDialog.setCancelable(false);
        
        // We should call network calls on separate thread not to freeze the application UI
        new Thread() {
            @Override
            public void run() {
                // Create 4shared API local layer to call remote methods
                ForSharedService fss = new ForSharedService(username, password);
                try {
                    // Call login procedure
                    fss.login();
                    // Get account's root folder
                    AccountItem rootItem = fss.getRoot();
                    // Request contents of the root folder
                    rootContents = fss.getItems(rootItem.getId());
                    
                    // If we are here, this means all the operations succeeded
                    loginSucceeded();
                } catch (Exception e) {
                    // One of the operations has failed
                    loginFailed(e.getMessage());
                }
            }
        }.start();
    }

If the name (login) and password correspond to the account in 4shared database, and network connection has been set successfully, the call up of the method loginSucceeded () opens the window (en. activity), which displays the list of user’s files and catalogues, which has been stored into the static variable rootContents.


    private void loginSucceeded() {
        // Application UI transitions should be performed on the main thread
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mProgressDialog.dismiss();
                // Move to next activity to show list of account's root folder contents
                Intent intent = new Intent(Hello4shared.this, AccountContents.class);
                startActivity(intent);
            }
        });        
    }

The last thing, which should be changed is the configuration of the project in the file AndroidManifest.xml.

In the section <manifest> let’s request the permit to get the access of the application to the Internet:


                <uses-permission android:name="android.permission.INTERNET"></uses-permission>
       In the section <application>, let’s add the window(activity) AccountContents:
       		<activity android:name=".AccountContents"
		          android:label="@string/app_name">
		</activity>
       and define the portrait orientation for the window (activity) Hello4shared:
       	        android:configChanges="keyboardHidden|orientation"
                android:screenOrientation="portrait"

The full code of the demo-application is attached (http://dc243.4shared.com/download/l8R381Nw/androidsamples.zip).


5. Run the Application (http://developer.android.com/resources/tutorials/hello-world.html)

Image3.png



Blackberry



System requirements:


- 32-bit Windows® XP, Windows Vista® or Windows 7 (64-bit versions require 32-bit Java® и Eclipse)

- Eclipse 3.6 Helios

- PC with processor Intel® Pentium® 4 or higher (2.5 GHz or higher, 2 GB RAM, 1.5 GB free space on hard drive)

- Java SE Development Kit (JDK) 6, update 10 or newer.


Setup:


-Download and install 32-bit version of JAVA (http://www.java.com/ru/download/)

-Download and install 32-bit version of Eclipse (http://www.eclipse.org/downloads/packages/eclipse-classic-362/heliossr2)

-Download and install Blackberry plugin for Eclipse (http://us.blackberry.com/developers/javaappdev/javaplugin.jsp)

-Install Blackberry SDK. To do this, to start Eclipse and check menu Help - Install New Software… In a line with the software address to insert http://www.blackberry.com/go/eclipseUpdate/3.6/java.


1. Description of 4shared Service


Service 4shared is a usual web-service, WSDL description of which is here: https://api.4shared.com/jax2/DesktopApp?wsdl.

You can read more about web-services and WSDL here: http://ru.wikipedia.org/wiki/%D0%92%D0%B5%D0%B1-%D1%81%D0%BB%D1%83%D0%B6%D0%B1%D0%B0, http://ru.wikipedia.org/wiki/WSDL.

Short description of API functions can found here: http://help.4shared.com/index.php/SOAP_API.

To work with SOAP API, you can use direct SOAP-calling, but it’s more convenient to use another library for request parsing. For instance, you can use free library: (http://code.google.com/p/ksoap2-android/), which uses Java Microedition, working on Blackberry OS).


2. Demo Application


In the beginning, it’s necessary to create the new project in Eclipse (menu File-New-Project, in the list of project types – select Blackberry Project) and call it Hello4Shared.

In addition to that, for the right setup on the device of library ksoap2, you should create the 2nd project, where to place the library. You should define the type of the 2nd project Library and add the link to this project in the main application.

To work with the service, it’s necessary to add subclass ForSharedService.

The standard call of the function 4shared API will be the following:


protected static final String SERVICE_URL = "http://api.4shared.com/jax2/DesktopApp";        
    protected static final String SERVICE_NAMESPACE = "http://api.soap.shared.pmstation.com/";
 
/**
* Enter check of the already existing user 
* @param username – user name
* @param password - password
* @throws Exception
*/
 public void login(String username, String password) throws Exception
 {
 	String methodName = "login";
      SoapObject rpc = new SoapObject(SERVICE_NAMESPACE, methodName);
      rpc.addProperty("arg0", userName);
      rpc.addProperty("arg1", password);

SoapSerializationEnvelope envelope = new    SoapSerializationEnvelope(SoapEnvelope.VER11);

      envelope.bodyOut = rpc;        
      envelope.encodingStyle = SoapSerializationEnvelope.XSD;

      HttpTransport ht = new HttpTransport(SERVICE_URL);
	ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	ht.debug = true;

        
      String result;

      ht.call(SERVICE_URL + "/" + methodName, envelope);
	result = (envelope.getResponse()).toString();         
        
      if (!isEmptyString(result))
      	throw new Exception(result);
}

The classes SoapObject, SoapSerializationEnvelope, HttpTransport – are included in the library ksoap2.

SoapObject, SoapSerializationEnvelope serve to parse soap-requests, whereas HttpTransport provides transport for the call of requests. The call of service functions itself is established by the method), of the class HttpTransport. The service answer can be received by means of calling the method getResponse() of the class SoapSerializationEnvelope. The parameters of functions, transferred to the service, are defined by calling up the method addProperty of the class SoapObject as a pair «parameter name - value». Now, let’s add the class of the main screen into the app, where we will place 2 text fields to enter the user’s name (login) and password, and the button to call up the method login of service, used to enter: public class MainAppScreen extends MainScreen implements FieldChangeListener

{
	/**
	 * Window Title
	 */
	private LabelField _title;
	
	/**
	 * Enter-Login Field
	 */
	private EmailAddressEditField _userNameField;
	
	/**
	 * Enter-Password Field
	 */
	private PasswordEditField _passwordField;
	
	/**
	 * Enter Button
	 */
	private ButtonField _loginButton;

	/**
	 * Constructor
	 */
	public MainAppScreen()
	{
		super();

		_title = new LabelField("Hello4Shared");
		setTitle(_title);
		
		_userNameField = new EmailAddressEditField("Login or email: ", "");
		add(_userNameField);
        _passwordField = new PasswordEditField("Password: ", "");
		add(_passwordField);

		_loginButton = new ButtonField("Login", Field.FOCUSABLE);
		_loginButton.setChangeListener(this);
		add(_loginButton);
	}
	
}

After that, let’s add the handler of the press-button in the following way:


/* 
 * The Handler of the Press-Button
*/
public void fieldChanged(Field field, int context)
{
	if (field == _loginButton)
	{
		login();
	}
}

And the exact request to 4shared service in the method login, by means of using the class ForSharedService, described above:


private void login(){
ForSharedService service = new ForSharedService(_userNameField.getText(), _passwordField.getText());
		
	// Logging into account
	try
	{
		service.login();
	}catch (Exception e)
	{
		Dialog.alert(e.getMessage());
	}
}

In case of invalid login or password, the user will receive the error report.

The full code of the demo-application is attached (http://dc315.4shared.com/download/bjixhTFj/blackberrysamples.zip).



Method Summary

addToFavorites

long addToFavorites(java.lang.String login, java.lang.String password, long fileId) Adds file to user favorites.

addToMyAccount

java.lang.String addToMyAccount(java.lang.String login, java.lang.String password, long dirId, java.lang.String link) Adds file or folder identified by supplied link to user's account in folder identified by dirId

checkSharedDirAccess

int checkSharedDirAccess(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword) Checks if directory can be accessed by specified user with specified passwords

createNewFolder

long createNewFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String folderName) Creates new folder as dirId subfolder

createUploadSessionKey

java.lang.String createUploadSessionKey(java.lang.String login, java.lang.String password, long dirID) Creates session key for uploading file

decodeId

java.lang.String decodeId(java.lang.String login, java.lang.String password, java.lang.String encodedId) turns new encoded folder id into form id+"/"+4shared_password for shared folder browsing encoded folder id can be found as 8-symbol group of folder url right after /dir/ regexp: http://www.4shared.com/dir/(.{8,8})/.*

decodeLink

long decodeLink(java.lang.String login, java.lang.String password, java.lang.String link) Used to get item id from item link.

deleteFile

void deleteFile(java.lang.String login, java.lang.String password, long fileID) Removes file to recycle bin

deleteFileFinal

void deleteFileFinal(java.lang.String login, java.lang.String password, long fileID) Remove file once and for all.

deleteFolder

void deleteFolder(java.lang.String login, java.lang.String password, long dirID) Completely removes folder and puts all of it contents to recycle bin

deleteFolderFinal

void deleteFolderFinal(java.lang.String login, java.lang.String password, long dirID) Removes files and subfolders from recycle bin.

downloadFinished

void downloadFinished(java.lang.String login, java.lang.String password, long fileId) Have to be called after full file download

emptyRecycleBin

int emptyRecycleBin(java.lang.String login, java.lang.String password) Empties recycle bean for specified user.

getAllFolders

AccountItem[] getAllFolders(java.lang.String login, java.lang.String password) Returns all of the folders in user's root directory

getAllItems

AccountItem[] getAllItems(java.lang.String login, java.lang.String password) Returns info about all items in user's root folder

getDirDescription

java.lang.String getDirDescription(java.lang.String login, java.lang.String password, long dirId) Returns folder description

getDirectLink

java.lang.String getDirectLink(java.lang.String login, java.lang.String password, java.lang.String link) Returns link to start immediate downloading.

getDirInfo

AccountItem getDirInfo(java.lang.String login, java.lang.String password, long dirID) Return info about specified folder

getExifFileInf

ExifInfo getExifFileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink) Return image info for specified file link if any

getExifFileInfos

ExifInfo[] getExifFileInfos(java.lang.String login, java.lang.String password, long dirId) Returns @see ExifInfo for all image files in specified folder

getFavorites

AccountItem[] getFavorites(java.lang.String login, java.lang.String password) Returns user favored files.

getFileDescription

java.lang.String[] getFileDescription(java.lang.String login, java.lang.String password, long fileId) Returns file title, tags and description if any

getFileDownloadLink

java.lang.String getFileDownloadLink(java.lang.String login, java.lang.String password, long fileID) Returns download link for user owned file

getFileInfo

AccountItem getFileInfo(java.lang.String login, java.lang.String password, long fileID) Returns info about file

getFiles

AccountItem[] getFiles(java.lang.String login, java.lang.String password, long[] fileIds) Returns account items for file ids.

getFreeSpace

long getFreeSpace(java.lang.String login, java.lang.String password) Gets free space left for user

getItemInfo

AccountItem getItemInfo(java.lang.String login, java.lang.String password, long itemID, boolean dir) Common method for DesktopApp.getFileInfo(String, String, long) and DesktopApp.getDirInfo(String, String, long) distinguished by value of dir parameter

getItems

AccountItem[] getItems(java.lang.String login, java.lang.String password, long dirID) Returns array of infos about contents of specified dir.

getSharedDirItems

AccountItem[] getDirLinkItems(String dirLink, String userDirPassword). Returns array of infos about contents of specified dir accepting the folder link.

getItemsCount

long getItemsCount(java.lang.String login, java.lang.String password, long dirID) Returns item count for dirId (-1 for root folder)

getItemsPartial

AccountItem[] getItemsPartial(java.lang.String login, java.lang.String password, long dirId, int startIndex, int count) Get specified count folders' items ordered by name, folders first starting from startIndex

getMaxFileSize

long getMaxFileSize(java.lang.String login, java.lang.String password) Return maximum allowed file size for specified user

getMp3FileInfo

Mp3Info getMp3FileInfo(java.lang.String login, java.lang.String password, java.lang.String fileLink) Return audio info for specified file link if any

getMp3FileInfos

Mp3Info[] getMp3FileInfos(java.lang.String login, java.lang.String password, long dirId) Returns audio info for all audio files in folder

getNewFileDataCenter

long getNewFileDataCenter(java.lang.String login, java.lang.String password) Returns datacenter id to upload files to

getNotOwnedSizeLimit

long getNotOwnedSizeLimit() Max file size which can be downloaded without speed limit

getPreviewLink

java.lang.String getPreviewLink(java.lang.String login, java.lang.String password, long fileId) Return link to small preview image, or to flv preview for video files

getRecycleBinItems

AccountItem[] getRecycleBinItems(java.lang.String login, java.lang.String password) Returns info about files in recycle bin

getRoot

AccountItem getRoot(java.lang.String login, java.lang.String password) Returns account item for user's root directory

getSharedDirItems

AccountItem[] getSharedDirItems(java.lang.String login, java.lang.String password, long dirID, java.lang.String dirPassword, java.lang.String userDirPassword) Return content of possibly not owned shared folder

getSpaceLimit

long getSpaceLimit(java.lang.String login, java.lang.String password) Returns user space limit

getUploadFormUrl

java.lang.String getUploadFormUrl(int dataCenterID, java.lang.String sessionKey) Returns url to upload file to.

hasRightUpload

boolean hasRightUpload() Whether upload feature is on.

isAccountActive

boolean isAccountActive(java.lang.String login, java.lang.String password) Checks account active status

isAccountBanned

boolean isAccountBanned(java.lang.String login, java.lang.String password) Checks if user account is banned

isAccountPremium

boolean isAccountPremium(java.lang.String login, java.lang.String password) Checks if user account is premium

isExistsLoginPassword

boolean isExistsLoginPassword(java.lang.String login, java.lang.String password) true-false version of login.

login

java.lang.String login(java.lang.String login, java.lang.String password) Login version with diagnostic message.

pasteFilesDirs

java.lang.String pasteFilesDirs(java.lang.String login, java.lang.String password, long toFolderId, boolean makeCopy, long[] fileIds, long[] dirIds) Copy-pastes or cut-pastes a group of files and dirs.

removeFromFavorites

long removeFromFavorites(java.lang.String login, java.lang.String password, long fileId) Removes file from user's favorites.

renameFile

long renameFile(java.lang.String login, java.lang.String password, long fileID, java.lang.String newName) Renames specified file

renameFolder

long renameFolder(java.lang.String login, java.lang.String password, long dirID, java.lang.String newName) Renames specified folder

restoreFile

void restoreFile(java.lang.String login, java.lang.String password, long fileID) Restores file from Recycle Bin.

restoreFiles

void restoreFiles(java.lang.String login, java.lang.String password, long[] fileIDs) Restores group of files from Recycle Bin.

setDirDescription

java.lang.String setDirDescription(java.lang.String login, java.lang.String password, long dirId, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll) Sets folder description for dedicated folder or account as a whole

setFileDescription

java.lang.String setFileDescription(java.lang.String login, java.lang.String password, long fileId, java.lang.String title, java.lang.String tags, java.lang.String newDescription, boolean setAsDefault, boolean applyToAll) Sets file title, tags and description for dedicated file or account as a whole

signup

java.lang.String signup(java.lang.String login, java.lang.String password) Creates new User with specified login(email) and password and sends confirmation email.

signupUsername

java.lang.String signupUsername(java.lang.String login, java.lang.String password, java.lang.String username) Creates new User with specified login(email), short username for easing login and password and sends confirmation email.

uploadCancelFile

void uploadCancelFile(java.lang.String login, java.lang.String password, long fileId) Call if upload was canceled

uploadFinishFile

java.lang.String uploadFinishFile(java.lang.String login, java.lang.String password, long fileId, java.lang.String md5) Complete resumable upload

uploadStartedFileExists

boolean uploadStartedFileExists(java.lang.String login, java.lang.String password, long fileId) Checks if file was partially uploaded

uploadStartFile

long uploadStartFile(java.lang.String login, java.lang.String password, long dirID, java.lang.String name, long fullSize) Resumable upload - start

uploadStartFileUpdate

long uploadStartFileUpdate(java.lang.String login, java.lang.String password, long updateFileId, java.lang.String name, long fullSize) Update file

Method Detail

Upload HOW TO

First of all you should check if you have enough free space in user’s account:

 function long getFreeSpace(String login, String password);

(returned value – free space in bytes)

And what is upload limit for user (per file):

 function long getMaxFileSize(String login, String password);

(returned value – maximum file size in bytes)

Please, check if target file corresponds the mentioned conditions, if it does, then:

Get session:

function String createUploadSessionKey(String login, String password, long dirID);

Set ‘-1’ as DirId parameter. In this case file will be uploaded to the root directory.

Or read full API description to learn how to browse user's directory for subdirectories' ids.

Return session key if everything is ok and empty or null string if you can't upload to the specified dir.

Get datacenter:

 function int getNewFileDataCenter(String login, String password);

If returned datacenter is less or equal then 0 - something goes wrong.

Then get URL for upload using session and datacenter:

 function String getUploadFormUrl(int dataCenterID, String sessionKey);

Returned string is only valid if it starts with http, otherwise, you can't upload file;

To reserve fileId for yor upload call function:

 function long uploadStartFile(String login, String password, long dirID, String name, long fullSize);

Again, fileId can be only positive.

Then use received URL and fileId to upload by executing POST query multipart/form-data with fields

1) resumableFileId (file ID received via previous method)

2) resumableFirstByte (index of the first byte of current part. If the file is uploaded as single unit – then pass 0. If the file is divided into parts and is uploaded by parts – then pass index of the byte every part starts from)

Attach the file to the query as a parameter FilePart.

where last parameter is file md5 digest. If the file is successfully uploaded – function returns null or empty line, if not – you will get an error message. If the file was uploaded by parts, this function unites them into one.

You are done!

Search files on 4shared

To search files on 4shared.com you should use the following url

http://search.4shared.com/network/searchXml.jsp

Parameters:

       q - keyword

Example: q=funny cats

       searchExtention - type of file (extension)
       
       searchCategory - category
       

If you need extension just use searchExtention=mid. Remember, if you are using parameter searchExtention you should also use searchmode=3


For searching in category use the following:

       searchCategory=music/audio
       searchCategory=video
       searchCategory=photo
       searchCategory=archive
       searchCategory=office/books_office/document/books
       searchCategory=program
       searchCategory=web 
       searchCategory=mobile/mobile_palm
       searchCategory=game

Example: use searchCategory=audio - if you are searching only for music.

Remember, if you are using parameter searchCategory you should also use searchmode=3

       sortType - type of sorting
         1 - sort by downloads;
         2 - sort by upload date;
         3 - sort by size;
         4 - sort by name;
       sortOrder - sorting order(Ascending -1, Descending 1)
       start - offset, is used for pagination

start value should be divisible by 10


Usage example:

http://search.4shared.com/network/searchXml.jsp?q=somebody&searchExtention=mid&sortType=3&sortOrder=1&searchmode=3&start=10

Response:

<search-result>
<query>somebody</query> - keyword
<total-files>24</total-files> - number of found files
<page-number>2</page-number> - page number
<pages-total>2</pages-total> - total amount of pages
<start>10</start> - offset
<files-per-page>10</files-per-page> - amount of files per page
<files-approx-count>24</files-approx-count> - approximate number of files (when amount of found files is more than 1,000). If amount of found files is less than 1,000 it equals to <total-files></total-files>
<result-files>
<file>
<name>somebody_to_shove.mid</name> - filename
<description/> - description
<downloads-count>8</downloads-count> - number of downloads
<upload-date-format>hh:mm dd-MM-yyyy</upload-date-format> - upload date format
<upload-date>04:19 19-05-2009</upload-date> - upload date
<url>http://www.4shared.com/audio/qVaKdItF/somebody_to_shove.htm</url> - download page url
<preview-url/> - preview url if exist
<flash-preview-url/>- flash preview url if exist
<user>wym</user> - username
<size>39 KB</size> - file size
</file>
<file>
...
</file>
</result-files>
</search-result>

checkSharedDirAccess

 public int checkSharedDirAccess(java.lang.String login,
                               java.lang.String password,
                               long dirID,
                               java.lang.String dirPassword,
                               java.lang.String userDirPassword)

Checks if directory can be accessed by specified user with specified passwords

Parameters:

       login - is user login
       password - is user password
       dirID - id of the directory to be accessed
       dirPassword - generated password to view contents of not owned folders
       userDirPassword - user specified password 

Returns:

Status.
0 	ok
1 	no such dir
2 	owner inactive
3 	abused dir
4 	incorrect dirPassword
5 	dir is not shared
6 	owner is banned
8 	incorrect userDirPassword

checkSubdomain

 public java.lang.String checkSubdomain(java.lang.String login,
                                      java.lang.String password,
                                      long dirId,
                                      java.lang.String subdomainName)

Checks if subdomain can be set for specified folder

Parameters:

 login - user login
 password - user password
 dirId - id of the directory
 subdomainName - name to be set 

Returns:

 Empty string or null if everything is ok and error message otherwise

createNewFolder

 public long createNewFolder(java.lang.String login,
                           java.lang.String password,
                           long dirID,
                           java.lang.String folderName)

Creates new folder as dirId subfolder

Parameters:

 login - user login
 password - user password
 dirID - id of the directory to create folder in
 folderName - new folder name 

Returns:

 0 - if creation denied, newly created dir ID otherwise 
 -1 - already exists 
 -2 - attempt to create folder in removed parent

createUploadSessionKey

 public java.lang.String createUploadSessionKey(java.lang.String login,
                                              java.lang.String password,
                                              long dirID)

Creates session key for uploading file

Parameters:

 login - user login
 password - user password
 dirID - id of the directory to upload to 

Returns:

 session key

deleteFile

 public void deleteFile(java.lang.String login,
                      java.lang.String password,
                      long fileID)

Removes file to recycle bin or from recycle bin if it is already there

Parameters:

 login - user login
 password - user password
 fileID - id of the file to be removed

deleteFolder

 public void deleteFolder(java.lang.String login,
                        java.lang.String password,
                        long dirID)

Completely removes folder and puts all of it contents to recycle bin

Parameters:

 login - user login
 password - user password
 dirID - id of the directory to be removed

downloadFinished

 public void downloadFinished(java.lang.String login,
                            java.lang.String password,
                            long fileId)

Have to be called after full file download

Parameters:

 login - user login
 password - user password
 fileId - id of the file which was downloaded

getAllFolders

 public com.pmstation.shared.soap.api.AccountItem[] getAllFolders(java.lang.String login,
                                                                java.lang.String password)

Returns all of the folders in user's root directory

Parameters:

 login - user login
 password - user password 

Returns:

 Array of info records about user's root folder subfolders

getAllItems

 public com.pmstation.shared.soap.api.AccountItem[] getAllItems(java.lang.String login,
                                                              java.lang.String password)

Returns info about all items in user's root folder

Parameters:

 login - user login
 password - user password 

Returns:

 Array of info records about user's root folder content

getCurrentUploaderVersion

 public long getCurrentUploaderVersion()

Returns last uploader version. If this increase you should consider to look at online api documentation to check changes. We will try to maintain backward compatibility but this is not guaranteed.

Returns:

 Uploader version

getDirectLink

 public java.lang.String getDirectLink(java.lang.String login,
                                     java.lang.String password,
                                     java.lang.String link)

Returns link to start immediate downloading. Not always possible however, because we are ads-supported mostly. Returns link starting with "http" if ok.

Parameters:

 login - user login
 password - user password
 link - indirect download link

getDirInfo

 public com.pmstation.shared.soap.api.AccountItem getDirInfo(java.lang.String login,
                                                           java.lang.String password,
                                                           long dirID)

Return info about specified folder

Parameters:

 login - user login
 password - user password
 dirID - id of the folder 

Returns:

 folder info

getFileDownloadLink

 public java.lang.String getFileDownloadLink(java.lang.String login,
                                           java.lang.String password,
                                           long fileID)

Returns download link for user owned file

Parameters:

 login - user login
 password - user password
 fileID - id of file to be downloaded 

Returns:

 Download link or empty string if some errors occurs.

getFileInfo

 public com.pmstation.shared.soap.api.AccountItem getFileInfo(java.lang.String login,
                                                            java.lang.String password,
                                                            long fileID)

Returns info about file

Parameters:

 login - user login
 password - user password
 fileID - id of file to get info about 

Returns:

 file info

getFolderSharingProperties

 public com.pmstation.shared.soap.api.SharedFolderProperties[] getFolderSharingProperties(java.lang.String login,
                                                                                        java.lang.String password,
                                                                                        long dirId)

Returns folder sharing properties. Output is two element array: res[0] - actual values. res[1] - properties which can be set for this user is marked as true.

Parameters:

 login - user login
 password - user password
 dirId - id of the folder to properties for

Returns:

 folder sharing properties

getFreeSpace

 public long getFreeSpace(java.lang.String login,
                        java.lang.String password)

Gets free space left for user

Parameters:

 login - user login
 password - user password 

Returns:

 free space left for user in bytes

getHistory

 public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistory(java.lang.String login,
                                                               java.lang.String password,
                                                               long dirId)

Returns history of operations in specified folder and subfolders. For operation field meanings see getOperationDescriptions()

Parameters:

 login - user login
 password - user password
 dirId - id of folder 

Returns:

 Array of folder changes. May be null or empty

getHistoryFromId

 public com.pmstation.shared.soap.api.DirHistoryDTO[] getHistoryFromId(java.lang.String login,
                                                                     java.lang.String password,
                                                                     long dirId,
                                                                     long fromId)

Returns history of operations which occurs in specified folder and subfolders with history id more then specified. For operation field meanings see getOperationDescriptions()

Parameters:

 login - user login
 password - user password
 dirId - id of folder to take history for
 fromId - id floor of history 

Returns:

 Array of folder changes. May be null or empty

getItemInfo

 public com.pmstation.shared.soap.api.AccountItem getItemInfo(java.lang.String login,
                                                            java.lang.String password,
                                                            long itemID,
                                                            boolean dir)

Common method for getFileInfo(String, String, long) and getDirInfo(String, String, long) distinguished by value of dir parameter

Parameters:

 login - user login
 password - user password
 itemID - id of element
 dir - if true then supplied Id is folder and file otherwise 

Returns:

getItems

 public com.pmstation.shared.soap.api.AccountItem[] getItems(java.lang.String login,
                                                           java.lang.String password,
                                                           long dirID)

Returns array of infos about contents of specified dir.

Parameters:

 login - user login
 password - user password
 dirID - id of folder to list (-1 for root)

Returns:

 Array of info items

getMaxFileSize

 public long getMaxFileSize(java.lang.String login,
                          java.lang.String password)

Return maximum allowed file size for specified user

Parameters:

 login - user login
 password - user password

Returns:

 maximum allowed file size in bytes

getNewFileDataCenter

 public long getNewFileDataCenter(java.lang.String login,
                                java.lang.String password)

Returns datacenter id to upload files to

Parameters:

 login - user login
 password - user password 

Returns:

 datacenter id to upload new files to

getNotOwnedSizeLimit

 public long getNotOwnedSizeLimit()

Max file size which can be downloaded without speed limit

Returns:

 max file size which can be downloaded without speed limit

getOperationDescriptions

public java.lang.String[] getOperationDescriptions()

Returns array of OperationEnum names. Array index corresponds to values which can be returned as DirHistoryDTO.getOperation(). Array is supposed to be zero-based.

Returns:

 array of OperationEnum names

getRecycleBinItems

 public com.pmstation.shared.soap.api.AccountItem[] getRecycleBinItems(java.lang.String login,
                                                                     java.lang.String password)

Returns info about files in recycle bin

Parameters:

 login - user login
 password - user password 

Returns:

 Array of recycle bin content info items

getSharedDirItems

 public com.pmstation.shared.soap.api.AccountItem[] getSharedDirItems(java.lang.String login,
                                                                    java.lang.String password,
                                                                    long dirID,
                                                                    java.lang.String dirPassword,
                                                                    java.lang.String userDirPassword)

Return content of possibly not owned shared folder

Parameters:

 login - user login
 password - user password
 dirID - id of folder to view
 dirPassword - 4shared generated dir password
 userDirPassword - user set dir password if needed 

Returns:

 content of specified shared folder or null

getSpaceLimit

 public long getSpaceLimit(java.lang.String login,
                         java.lang.String password)

Returns user space limit

Parameters:

 login - user login
 password - user password 

Returns:

 space limit

getUploadFormUrl

public java.lang.String getUploadFormUrl(int dataCenterID,

                                        java.lang.String sessionKey)

Returns url to upload file to.

Parameters:

 dataCenterID - id of datacenter to upload to
 sessionKey - upload session key

hasRightUpload

 public boolean hasRightUpload()

Whether upload feature is on.

Returns:

 whether upload feature is on.

isAccountActive

 public boolean isAccountActive(java.lang.String login,
                              java.lang.String password)

Checks account availability

Parameters:

 login - user login
 password - user password 

Returns:

 true if account is active

isAccountBanned

 public boolean isAccountBanned(java.lang.String login,
                              java.lang.String password)

Checks if user account is banned

Parameters:

 login - user login
 password - user password 

Returns:

 true if user accont is banned

isAccountPremium

 public boolean isAccountPremium(java.lang.String login,
                               java.lang.String password)

Checks if user account is premium

Parameters:

 login - user login
 password - user password 

Returns:

 true of user has premium account

isExistsLoginPassword

 public boolean isExistsLoginPassword(java.lang.String login,
                                    java.lang.String password)

true-false version of login

Parameters:

 login - user login
 password - user password 

Returns:

 true if login was successful

login

 public java.lang.String login(java.lang.String login,
                             java.lang.String password)

Login

Parameters:

 login - user login
 password - user password 

Returns:

 Empty string if all ok, diagnostic message otherwise

markSynchronized

 public void markSynchronized(java.lang.String login,
                            java.lang.String password,
                            long dirId)

Informs 4shared to write folder and subfolders usage history

Parameters:

 login - user login
 password - user password
 dirId - id of folder to write history for

pasteFilesDirs

 public java.lang.String pasteFilesDirs(java.lang.String login,
                                      java.lang.String password,
                                      long toFolderId,
                                      boolean makeCopy,
                                      long[] fileIds,
                                      long[] dirIds)

Copy-pastes or cut-pastes a group of files and dirs. Use this to copy or move a group of files to another directory.

Parameters:

 login - user login
 password - user password
 toFolderId - target folder id
 makeCopy - - exec copy+paste if true, exec cut+paste if false
 fileIds - ids of file to be moved/copied
 dirIds - ids of folders to be moved/copied 

Returns:

 diagnostic message or empty string if all ok

renameFile

 public long renameFile(java.lang.String login,
                      java.lang.String password,
                      long fileID,
                      java.lang.String newName)

Renames specified file

Parameters:

 login - user login
 password - user password
 fileID - id of file to be renamed
 newName - new name of file 

Returns:

 -1 if file exists, 
 0 in case of other failures, 
 fileID if rename was successful

renameFolder

 public long renameFolder(java.lang.String login,
                        java.lang.String password,
                        long dirID,
                        java.lang.String newName)

Renames specified folder

Parameters:

 login - user login
 password - user password
 dirID - id of folder to be renamed
 newName - new name of folder 

Returns:

 -1 if file exists, 
 0 in case of other failures, 
 dirID if rename was successful

restoreFile

 public void restoreFile(java.lang.String login,
                       java.lang.String password,
                       long fileID)

Restores file from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.

Parameters:

 login - user login
 password - user password
 fileID - id of file to be restored

restoreFiles

 public void restoreFiles(java.lang.String login,
                        java.lang.String password,
                        long[] fileIDs)

Restores group of files from Recycle Bin. If folder still exists restores to it, in other cases will restore to special RESTORED FILES folder which will be created if not already exists.

Parameters:

 login - user login
 password - user password
 fileIDs - Array of file ids to be restored

setFolderSharingProperties

 public java.lang.String setFolderSharingProperties(java.lang.String login,
                                                  java.lang.String password,
                                                  long dirId,
                                                  com.pmstation.shared.soap.api.SharedFolderProperties folderProperties)

Sets folder sharing properties

Parameters:

 login - user login
 password - user password
 dirId - id of folder to set properties for
 folderProperties - new properties values 

Returns:

 Diagnostic message or empty string if all is ok

signup

 public java.lang.String signup(java.lang.String login,
                              java.lang.String password)

Creates new User and sends confirmation email.

Parameters:

 login - desired login
 password - password 

Returns:

 error message if any. Empty string if all ok.

syncFinished

 public void syncFinished(java.lang.String login,
                        java.lang.String password,
                        long fileId)

Should be called in the end of each sync operation

Parameters:

 login - user login
 password - user password
 fileId - which file was synced. -1 if not applicable

uploadCancelFile

 public void uploadCancelFile(java.lang.String login,
                            java.lang.String password,
                            long fileId)

Call if upload was canceled

Parameters:

 login - user login
 password - user password
 fileId - id of file which upload is canceling

uploadFinishFile

 public java.lang.String uploadFinishFile(java.lang.String login,
                                        java.lang.String password,
                                        long fileId,
                                        java.lang.String md5)

Complete resumable upload

Parameters:

 login - user login
 password - user password
 fileId - returned from initial call to uploadStartFile() - existing file in 'being uploaded by parts' state
 md5 - original file MD5 to verify file consistency at server side 

Returns:

 empty string if success or error message

uploadStartedFileExists

 public boolean uploadStartedFileExists(java.lang.String login,
                                      java.lang.String password,
                                      long fileId)

Checks if file was partially uploaded

Parameters:

 login - user login
 password - user password
 fileId - id of file to be checked 

Returns:

 true if there is part of file already uploaded.

uploadStartFile

 public long uploadStartFile(java.lang.String login,
                           java.lang.String password,
                           long dirID,
                           java.lang.String name,
                           long fullSize)

Resumable upload - start

Parameters:

 dirID - (-1) means upload to user's root dir 

Returns:

 fileId to pass as parameter in all subsequent partial uploads

uploadStartFileUpdate

 public long uploadStartFileUpdate(java.lang.String login,
                                 java.lang.String password,
                                 long updateFileId,
                                 java.lang.String name,
                                 long fullSize)

Update file

Parameters:

 login - user login
 password - user password
 updateFileId - it of original file to be updated
 name - empty string means don't change existing name
 fullSize - 

Returns:

 id of temporary file uploading of which will cause update of original file