|SMEStorage php sample|
I have did some libs for SMEStorage.com API . Also i communicated with programmers that used SMEStorage API and i found that most difficult thing is to start using this API. For example, creating a folder or uploading a file. And next things are easy is this first tasks are done.
There i will describe how to create folder in SMEStorage with php.
I will create simple php library for this. Full SMEStorage API description should be there http://code.google.com/p/smestorage/
Main file (test.php) that will test library has code:
Lets analize library lib.php line by line.
First line defines API base url.
Then including php class that parses xml. It will be used to parse API response.
And last line there is declaration of the variable where API token will be stored. One get, the token is used for all API calling during a session.
This is function that sends API request and parse response.
The function can be splited for 2 parts: first part sends request and gets response and second part parses xml response.
Function gets API request url and only adds correct API server host to the url. Combining of the url is in response of functions that will call function processRequest .
SMEStorage API url is in format:
Next is function that does user Auth.
This is function that requests a token for user session. User login and password are sent as arguments.
API request url for getting token is:
There it is needed to describe function encodeArgs that encoded arguments set to required format. Arguments are set without names, so argument order is important. Read more in API manual.
At last there is function that creates a folder.
API function requires 3 arguments: folder name, folder description and parent folder id.
Full example code can be downloaded there in Downloads area - download SMEStorage API sample 1
|Last Updated on Friday, 12 February 2010 12:46|