Community

processFields how to include processing parameters in request body - PHP Answered

Hi,

As per stated in the processFields API info: "The XML file with the parameters of processing is transmitted in the request body".

In PHP, the file to be processed is transmitted in the request body as follows:

$post_array = array( "my_file"=>"@".$filePath, ); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array);

How should I include the processing parameters XML file into the request body? What should the file be named in the post_array?

Thanks, Adam

Was this article helpful?

0 out of 0 found this helpful

Comments

7 comments

  • Avatar
    Dmitry Mesheryakov

    my_file is just a key for the array, it can really be any string. The filepath is encoded by "@".$filePath which is literal @ prepending the file path.

    processFields accepts three parameters as described in the documentation. Two parameters - task id and description - go in the URL and the third one is the XML you're asking about. Since you don't submit anything else the XML file is the only file being submitted. So you can just set $filePath to contain the path to the XML file and use the same code as in your question:

    $post_array = array( "my_file"=>"@".$filePath, );
    curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array);
    
    0
  • Avatar
    greatrat00

    And how do I include the processing parameter xml file in the request body? Do I include it in the array as well?

    0
  • Avatar
    Dmitry Mesheryakov

    I updated my answer. Questions like this one are better asked as comments to the unclear answer.

    0
  • Avatar
    greatrat00

    Dmitry, thanks for your answer.

    I'm currently using the filePath to send the pdf file that I'm doing OCR on. How do I send that file if the array will now be filled with the processing parameter XML file?

    Thanks again!

    0
  • Avatar
    Dmitry Mesheryakov

    @greatrat00: First you set filePath to the PDF file, construct the POST parameters array and use submitImage to send the pdf file. You will now have the "task id". Then you set filePath to the settings XML file, again construct the POST parameters array and use processFields which will trigger actual processing.

    0
  • Avatar
    ronaktal

    What if I needed to submit it as a URL from PHP with the post raw data can I do that?

    0
  • Avatar
    Dmitry Mesheryakov

    You've asked that as a separate question http://forum.ocrsdk.com/questions/343/ocr-url and that question will be answered when you provide enough details to that question.

    0

Please sign in to leave a comment.