Lulu Developer Forums

API Applications

RSS Feed

Can't able to create Project Using - PHP

    • Raja
    • Topic created 3 years ago

    Hi,

    I've integrated Lulu API with PHP, when i tempt to create project with the given input i'm getting the following error

    Given input which a json encoded PHP array,

    {"project_type":"hardcover","access":"private","bibliography":{"title":"Memoir Test Application","authors":[{"first_name":"Raja","last_name":"Ram"}],"category":2,"description":"This project is to test the application","language":"EN","country_code":"IN"},"physical_attributes":{"binding_type":"casewrap-hardcover","trim_size":"SIZE_825x1075","paper_type":"regular","color":false},"pricing":[{"total_price":"17.50","product":"download","currency_code":"USD"}],"file_info":[[{"mimetype":"application\/pdf","filename":"cover.pdf"},{"mimetype":"application\/pdf","filename":"content.pdf"}]]}

    Array
    (
    [error_value] => Both interior and cover documents must be stored.
    [error_type] => LApiInvalidArgumentsException
    )

    can anybody suggest me what went wrong in this and what exactly the error was. and here is my code

    $project_data = "api_key=" . urlencode($api_key) .
    "&auth_user=" . urlencode($auth_user) .
    "&auth_token=" . urlencode($auth_token) .
    "&project=" . urlencode(json_encode($project_input));

    curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch3, CURLOPT_POST, true);
    curl_setopt($ch3, CURLOPT_VERBOSE, true);
    curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch3, CURLOPT_POSTFIELDS, $project_data);

    $response3 = curl_exec($ch3);
    curl_close ($ch3);

    Regards,
    Raja.

    Message edited by Raja 2 years ago

  1. Josiah Gore3 years ago

    It looks like your file info is a list within a list, which is likely causing this error:

    "file_info": [[{"mimetype":"application\/pdf","filename":"cover.pdf"},{"mimetype":"application\/pdf","filename":"content.pdf"}]]
    should be
    "file_info": [{"mimetype":"application\/pdf","filename":"cover.pdf"},{"mimetype":"application\/pdf","filename":"content.pdf"}]

    When the API parses this JSON and looks for files, it is finding that your list contains only a single element - the other list. As a result it reacts as if you are specifying a single file.

  2. Raja3 years ago

    I've changed the JSON input as you have suggested, but still i am getting the same error,

    here is the JSON that i have posted,

    {"project_type":"hardcover","access":"private","bibliography":{"title":"Memoir Test Application","authors":[{"first_name":"Raja","last_name":"Ram"}],"category":2,"description":"This project is to test the application","language":"EN","country_code":"IN"},"physical_attributes":{"binding_type":"casewrap-hardcover","trim_size":"SIZE_825x1075","paper_type":"regular","color":false},"pricing":[{"total_price":"17.50","product":"download","currency_code":"USD"}],"file_info":[{"mimetype":"application\/pdf","filename":"cover.pdf"},{"mimetype":"application\/pdf","filename":"content.pdf"}]}

    and the result is like this,

    Array
    (
    [error_value] => Both interior and cover documents must be stored.
    [error_type] => LApiInvalidArgumentsException
    )

    I'll be much obliged if you could make this without error.I had spent much time in this API but still nothing get done.

  3. Josiah Gore3 years ago

    Ah yes, sorry, I told you wrong. The issue here is actually that you are not specifying the cover and contents correctly. file_info needs to be a dictionary like this:

    "file_info":{
    "cover": [{"mimetype":"application\/pdf","filename":"cover.pdf"}],
    "contents": [{"mimetype":"application\/pdf","filename":"content.pdf"}]
    }

    so that the API knows what the files you are specifying should be used for.

  4. Raja2 years ago

    Yes i had changed my code as per your suggestion, i got error

    Array
    (
    [error_value] => The size of your document is not the same as the size you chose for your book. You chose 15.24cm x 22.86cm, but your file is 21.59cm x 27.94cm.
    [error_type] => LApiPublishInvalidDocumentException
    )

    how can i change the size of the PFD, also there is an API available to generate PDF cover, similarly is there any API available to generate Content PDF ? if no,then how can i define the size of the content PDF as per your specification, say for example (15.24cm x 22.86cm )US_TRADE Trim size. Also when i used POCKET Trim size, i got error

    Input JSON :

    {"project_type":"hardcover","access":"private","bibliography":{"title":"Memoir Test Application","authors":[{"first_name":"Raja","last_name":"Ram"}],"category":2,"description":"This project is to test the application","language":"EN","country_code":"US"},"physical_attributes":{"binding_type":"jacket-hardcover","trim_size":"POCKET","paper_type":"regular","color":false},"pricing":[{"total_price":null,"product":"download","currency_code":null}],"file_info":{"cover":[{"mimetype":"application\/pdf","filename":"cover_new.pdf"}],"contents":[{"mimetype":"application\/pdf","filename":"contents.pdf"}]}}

    Array
    (
    [error_value] => The provided combination of physical properties is not supported.
    [error_type] => LApiPublishInvalidPackageException
    )

    Kindly let me know the solution earlier.

  5. Ryan Bloom2 years ago

    The easiest way to fix the first error is to change the requested trim_size argument. The PDF that you are supplying requires that you chooise a US_LETTER trim_size. At this time, we do not have APIs that will adjust the size of the submitted PDF. Your PDF generation tools should allow you to specify that as a part of creating the initial PDF.

    There is an API for generating the cover: http://developer.lulu.com/docs/read/pdfgen. This same API can be used to create the content PDF as well, but that API is still in beta, and requires that you provide the content in an XML format, and an XSLT for transforming the content into a PDF. If you would like to go that direction, we can look into setting it up for you. One of our future goals is to allow users to set this up without our involvement, but that still requires more thought.

    Ryan

  6. Raja2 years ago

    Fine, is there any tool available to change the size of the PDF ? It is better to send me the XML format that i need to send for content PDF generation
    also what does it mean XSLT kindly brief it. Do the needful earlier and let me know once it is completed. If it is possible send me the entire code in PHP to generate Content PDF via XML & XSLT. Looking forward for your reply.

    I need to get it done today. Kindly treat it as emergency and give priority to this.

    Thanks and Regards,
    Raja

  7. Ryan Bloom2 years ago

    The easiest way to find a tool that can change the size of a PDF is to use Google (http://www.google.com/search?q=change+PDF+dimensions+PHP&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a). I do not know your environment, nor which tools you have access to. In this query, I have assumed that you are using PHP based on your questions so far.

    XSLT is an XML transformation language and is the basis for our Cover and content PDF generation technology. The content PDF generation today is done by having the end-user (you) provide us with an XSLT stylesheet that converts your XML document into a PDF. Since we do not have access to your XML, we cannot create the stylesheet for you. One of our future goals is to have a VERY basic stylesheet that converts and ATOM or RSS feed into a PDF, but that isn't publicly available yet, and I can't guarantee that it would fit your situation if it was available.

    I will connect with you in a private message to discuss how we can best help you complete your project.

    Ryan

[ Page 1 of 1 ]