When you send a request to the server, it returns a response. All server responses have a common structure as follows:
<image_process_response> <request_id>REQUEST_ID</request_id> <status>STATUS</status> <description>DESCRIPTION</description> <err_code>ERROR_CODE</err_code> <result_url>URL1</result_url> <thumb1_url>URL2</thumb1_url> <thumb2_url>URL3</thumb2_url> <thumb_ini1_url>URL4</thumb_ini1_url> <thumb_ini2_url>URL5</thumb_ini2_url> </image_process_response>
When you send an add task request to the server, you get the following response (this response matches with the common response specification):
<image_process_response> <request_id>REQUEST_ID</request_id> <status>STATUS</status> <description>DESCRIPTION</description> <err_code>ERROR_CODE</err_code> </image_process_response>
The possible values of the tags are:
Tag | Value | Description |
---|---|---|
STATUS | OK | Means that the task was successfully added in the tasks queue. You can use the REQUEST_ID to check the task completion status and get the resulting image (see ‘Get result request’ section). |
STATUS | Error/SecurityError | An error occurred while processing the task. The error code will be returned into the <err_code> tag. (see Error codes for more information) |
When you send an add task
request to the server and get a response with STATUS = OK and ERROR_CODE =
0, it means you can get a resulting image by sending a get result request.
Here is a get result request format:
http://opeapi.ws.pho.to/getresult?request_id=:REQUEST_ID, where the REQUEST_ID is the ID you received in a response to the add task request.
The server returns an HTTP response to the get result request, which is an XML file. The format of this response matches with the common response specification:
<image_process_response> <request_id>REQUEST_ID</request_id> <status>STATUS</status> <description>DESCRIPTION</description> <err_code>ERROR_CODE</err_code> <result_url>URL1</result_url> <thumb1_url>URL2</thumb1_url> <thumb2_url>URL3</thumb2_url> <thumb_ini1_url>URL4</thumb_ini1_url> <thumb_ini2_url>URL5</thumb_ini2_url> </image_process_response>
add task
request and the
processing status.
Possible values of the <status> tag in a response to the get result request are described in the following table:
<status> tag value | Description |
---|---|
OK | The task is in progress, you need to wait for some time. |
InProgress | The task is in progress, you need to wait for some time. |
Error/SecurityError | An error has occurred while processing the task (see Error codes) |
WrongID | There is no task with such REQUEST_ID. |
In case of successful processing (<status>OK</status>), the response comes as an XML text file as follows (this response matches with a common response specification):
<image_process_response> <request_id>REQUEST_ID</request_id> <status>OK</status> <description>DESCRIPTION</description> <err_code>0</err_code> <result_url>URL1</result_url> <thumb1_url>URL2</thumb1_url> <thumb2_url>URL3</thumb2_url> <thumb_ini1_url>URL4</thumb_ini1_url> <thumb_ini2_url>URL5</thumb_ini2_url> </image_process_response>
If processing was not successful, the response comes as an XML text file as follows:
<image_process_response> <request_id>REQUEST_ID</request_id> <status>STATUS</status> <description>DESCRIPTION</description> </image_process_response>
Errors in a response to the get result request can be of two types: Error and SecurityError. The error type is located is the <status> tag.
An error of SecurityError type occurs when you send wrong APP_ID, KEY or SIGN_DATA (see Add
task request format).
An error of Error type occurs if there is a problem processing your add task
request.
The response with an error matches with the common response specification and looks as follows:
<image_process_response> <status>SecurityError/Error</status> <err_code>ERROR_CODE</err_code> <description>ERROR_DESCRIPTION</description> </image_process_response>
The <status> tag value can be of two types: Error and SecurityError.
<err_code> | <Description> |
---|---|
600 | No private key (KEY parameter) has been generated. |
606 | Invalid or bad APP_ID parameter. |
607 | This APP_ID is deactivated. |
608 | This APP_ID is out of date. |
609 | The limit on the amount of requests for this APP_ID was reached. |
612 | Bad, invalid or empty REQUEST_ID parameter. |
613 | Invalid SIGN_DATA parameter. |
614 | Error in POST parameters: one or more parameters (DATA , SIGN_DATA or APP_ID) are empty. |
<err_code> | <Description> |
---|---|
-1 | The server failed to process the request |
-2 | The requested URL from the <image_url> tag was not found |
-3 | Wrong method or parameter name |
-4 | Unknown server error. Contact the service developer |
-5 | Maximum server load reached, please try again later |
-6 | Source image from the <image_url> tag exceeds size limit |
-7 | The request has timed out. Contact the service developer |
-10 | Unknown format of the image from the <image_url> tag |
-1000 | Face is not found. Try a better quality portrait image |
-1001 | Bad points or rectangle in the 'rect' attribute of the <image_url> tag |
-1002 | Bad or small image |
-1003 | Template with the specified name is not found |
1 | Unknown error. Contact the service developer |
3 | Cannot spawn worker process |
4 | The <result_url> tag is missing in the response. Contact the service developer |