What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Creating variables to pass through Zazzle.com API

    Asked by jeffest on September 25, 2013 at 05:35 PM

    I've set up a page on my website that connects to the API from Zazzle.com so customers can add images to their products. As it is, their interface is confusing and what I'd like to do is have customers upload their own image on my webpage first, along with some optional text, and have those turned into variables that I can pass through the API url so it all shows up automatically. I already figured how to use Jotform to save files to my server using FTP and they all get unique file names which is great, but that's where I got stuck. Any suggestions?

    variables JotForm FTP unique
  • Profile Image
    JotForm Support

    Answered by Welvin on September 25, 2013 at 08:03 PM

    Hi,

    Basically, you have a form from Jotform then someone would submit to the form, and all the results should be pass to the API URL? If so, that is possible with Jotform.

    API URL as the Custom Thank You URL: Prepare the API URL using any Text Editors you have. Go to your form in our form editor, right click to the fields you want to get its result, click "properties" and copy the Field Name:

    Paste the Field Name exactly to the section in your API URL you want to display its result.

    Example:

    http://yourwebsite.com/methods/api&field={clickTo}

    After you build the URL with the field names on it, open your Thank You Settings and put it as your Custom Thank You URL. Guide here: Custom Thank You URL.

     

    Let us know if this sounds NOT the output you want OR if you need any further assistance about this function.

    Thanks

  • Profile Image

    Answered by jeffest on October 23, 2013 at 04:28 PM
    Hi, I finally got around to trying this out and while I'm able to upload the file to a folder on my domain there's a problem communicating with the Zazzle API.
    First, this is the API URL I placed in the "Custom Thank you". I've taken out alot of parameters to make it easier to see:
    http://www.zazzle.com/api/create/at-238489665052695864?coverimage={selectFile}
    And this is the error message I get returned:
    Zazzle API Error. Image failed to upload: target="_blank" href="http://www.jotform.us/uploads/jeffest/32955813251152/248368119202238243/sample.jpg" rel="nofollow"
    >http://www.jotform.us/uploads/jeffest/32955813251152/248368119202238243/sample.jpg
    Details
    Failed
    to upload the file(s).
    Please check that the path and image name are correct
    and have been properly URL encoded. Also, make sure you have target="_blank" href="http://www.zazzle.com/my/associate/domains" rel="nofollow" >declared
    your domains.
    See more >API documentation.
    I did declare the domain on Zazzle and the file I tested is called "sample", but I noticed it's being saved as "248368119202238243-sample.jpg", so maybe that's the problem? Thanks.
  • Profile Image
    JotForm Support

    Answered by Welvin on October 23, 2013 at 05:36 PM

    Hi,

    We'll need to check this and do a real submission from our end. We simply cannot tell you to change anything without having to check this. Can you also share with us how would we go on doing the same? 

    And, basically, you will need to capture the whole file URL and not just the name, right?

    Thanks

  • Profile Image

    Answered by jeffest on October 23, 2013 at 06:05 PM
    You may be right about needing the whole file name. Here's a link to the API. The last parameter, "coverimage" does include the entire url and file name, but that's all hardcoded. Zazzle recently changed their interface and kinda messed up all my work by removing categories on the sidebar and changing the sort order to popular. I really had everything set up perfect, but the way it is now all I can think to do is have the customer upload the image from my front end and then it'll go to Zazzle and hopefully make some sense. The other issue though is that I want the Thank you page to open in a new tab so that the front-end stays the same and then allow the customer to try out different pre-made designs like this one without having to re-upload the image. Having categories removed kinda messed all that up, but if I can get this idea to work then maybe I can still salvage this. Thanks again.
  • Profile Image
    JotForm Support

    Answered by Welvin on October 23, 2013 at 07:18 PM

    Yes, because they need to get the file and download it from the URL. I don't see any link from your last reply. Please send it again. Hopefully, I can find a solution so you can still use your form. 

    About the thank you page on a new tab, we don't have that settings but I think that be achieve by the use of your form source codes (How to Get Form Source Codes). I'm not really sure but let me see.

    Thanks for waiting.

  • Profile Image

    Answered by jeffest on October 24, 2013 at 08:52 PM
    I don't know why links never get through but I'll resend my previous email with visible links. Maybe Yahoo is stripping them out or something.
    Here's a link to the API.
    http://www.zazzle.com/api/create/at-238489665052695864?rf=238489665052695864&ax=DesignBlast&cg=196782936422748250&sr=250587208718699833&br=true&ed=true&continueUrl=http%3A%2F%2Fwww.musclecartees.com%2Fcustom-gifts%2F&rut=Go%20Back%20To%20MuscleCarTees.com&fwd=DesignTool&coverimage=http%3A%2F%2Fwww.musclecartees.com%2Fimages%2Fcustom%2Fferguson2.png
    The last parameter, "coverimage" does include the entire url and file
    name, but that's all hardcoded whereas I want the file name variable (hmm...maybe I need to hardcode the folder url?) Zazzle recently changed their interface
    and kinda messed up all my work by removing categories on the sidebar
    and changing the sort order to popular. I really had everything set up
    perfect, but the way it is now all I can
    think to do is have the customer upload the image from my front end:
    http://www.musclecartees.com/design-your-own/
    and then it'll go to Zazzle and hopefully make some sense. The other
    issue though is that I want the Thank you page to open in a new tab so
    that the front-end stays the same and then allow the customer to try out
    different pre-made designs like this one:
    http://www.zazzle.com/api/create/at-238489665052695864?rf=238489665052695864&ax=DesignBlast&cg=196811073112243190&sr=250587208718699833&br=true&ed=true&continueUrl=http%3A%2F%2Fwww.musclecartees.com%2Fcustom-gifts%2F&rut=Go%20Back%20To%20MuscleCarTees.com&fwd=ProductPage&coverimage3=http%3A%2F%2Fwww.musclecartees.com%2Fimages%2Fcustom%2Fferguson2.png
    without having to re-upload the image. Having categories removed kinda
    messed all that up, but if I can get this idea to work then maybe I can
    still salvage this. Thanks
    again.
    Jeff =)
  • Profile Image

    Answered by Cesar on October 25, 2013 at 12:09 AM

    On be half of our colleague, thank you for reposting the link information, once Welvin has a an update in regards to your issue, he will post his findings on this thread. Thank you again.

  • Profile Image

    Answered by Jeff on November 04, 2013 at 01:21 PM

    Hi, this is still unresolved and I have a feeling it's dropped off the radar. I tried hard-coding the folder where the uploaded image is being stored but there seems to be another problem that's preventing this from working.

    The test image that I'm uploading is called "sample.jpg", but when it's uploaded the filename changes to "249076186202754817-sample.jpg", which of course is correct since I don't want duplicate image names, but that ID number added to the file name doesn't seem to be included in the {selectFile} field.

    This is the latest error message I get from the API:

    Zazzle API Error. Image failed to upload:

    http://www.musclecartees.com/images/custom/ZazzleAPI/http://www.jotform.us/uploads/jeffest/32955813251152/249076186202754817/sample.jpg

    Details
    404 The file is not found.
    Please check that the path and image name are correct and have been properly URL encoded. Also, make sure you have declared your domains. (which I have)

    Actually, looking at the Zazzle API Error it looks like it's got the right folder on my domain but then it attaches the Jotform directory where the file is stored and messes it all up. I assumed {selectFile} had only the file name but maybe it has the entire directory structure? I'm thinking that could be it. Is there a field that just has the filename?

    Anyways, I hope you can make sense of it. It would really make my day if I could get this working before the holiday shopping kicks in. Thanks guys. =)

     

  • Profile Image
    JotForm Support

    Answered by KadeJM on November 04, 2013 at 02:28 PM

    Thank you for the Additional Information. You are correct about the reason that we did not receive the shared link. If you replied to us with a response through your email it is stripped out so that is why. So because of that it becomes necessary to reply here on your thread with links and screenshots that you wish to provide us with.

    It seems to me that somewhere along the way there is a Parameter problem which is failing in the Validation to trigger the API being used but I can't say for certain just yet without playing around with this coding a lot more. I've signed up with Zazzle to take a deeper look at how their API's are being used to see what else we can do for you in regards to attempting this sort of build. I think that it would likely have to catch our parameters but seems this is just getting rejected based on what you've already shown us previously. I will look into this some more and also discuss it with my colleague Welvin as soon as he comes online and we'll get back to you as soon as possible.

  • Profile Image

    Answered by jeffest on November 04, 2013 at 02:34 PM
    Thanks, I really appreciate it.
  • Profile Image

    Answered by jeffest on November 06, 2013 at 09:14 PM
    This is the email for the developers at Zazzle that I've been in
    contact with and they said you could contact them with any questions
    about the API.
    dev.support@zazzle.com
  • Profile Image
    JotForm Support

    Answered by EltonCris on November 07, 2013 at 04:41 AM

    @jeffest

    Thanks for your reply.

    If I am not mistaken, you're getting an error since there are two different URLs, it's your API URL  and the generated file URL from Jotform. Obviously that will not work on the browser. 

    Also, the fact that the upload variable e.g. {selectfile} generates the full URL of the file like below, you won't be able to target the file uploaded to your FTP.

    http://www.jotform.us/uploads/jeffest/32955813251152/249076186202754817/sample.jpg

    Numbers in red is the submissions ID. It is unique and generated on the server side. It's constant variable is {id}.

    For the files uploaded via FTP, file names are prefixed with submissions IDs e.g. 249076186202754817-sample.jpg. As seen here: http://www.musclecartees.com/images/custom/ZazzleAPI/

    The best way to achieve this is to use POST DATA. Send POST Data From JotForm Using PHP in Custom Thank You Page. This will enable you to create a custom tag to target the uploaded files on your FTP.

    Here's an example PHP script. Please refer to the Post Data guide above.

    <?php

    $url = "http://www.musclecartees.com/images/custom/ZazzleAPI/";

    $submissionsID = $_POST['submission_id'];

    $file = $_POST['selectfile'];//change selectfile with your upload field name

    echo $url.$submissionsID."-".$file;

    ?>

    If you need further assistance, do let us know here. Thanks!

  • Profile Image

    Answered by jeffest on November 07, 2013 at 02:58 PM
    Hi, that looks very promising but PHP is not my specialty. I tried adding the rest of the Zazzle API with all the parameters into $url and I saved everything as "zazzle.php" and then placed that file name in the Thank You page, but all it did was display the variable data without executing it. However when I copied and pasted that into my browser it actually worked! So, we're really close on this. =)
    Maybe "echo" isn't the right command?
  • Profile Image

    Answered by jeanettebmz on November 07, 2013 at 04:22 PM

    It would be useful for us to see the final PHP script you came out with.

    I would think that if you are using the variable $url and added it to the Zazzle API, you can rather try Webhooks, which would replace using the Custom thank you page.

     

    Also, it would be great to have further information on regards to that API, probably our developers might help us with this.

  • Profile Image

    Answered by jeanettebmz on November 07, 2013 at 04:24 PM

    Please find more information about Webhooks and JotForm API here

  • Profile Image

    Answered by jeffest on November 07, 2013 at 04:37 PM
    Thanks I'll try the webhooks. Here's the script I tried using:
    <?php
    $url = "http://www.zazzle.com/api/create/at-238489665052695864?rf=238489665052695864&ax=DesignBlast&cg=196782936422748250&sr=250587208718699833&br=true&ed=true&st=date_created&continueUrl=http%3A%2F%2Fwww.musclecartees.com%2Fcustom-gifts%2F&rut=Go%20Back%20To%20MuscleCarTees.com&fwd=DesignTool&coverimage=http%3A%2F%2Fwww.musclecartees.com%2Fimages%2Fcustom%2FZazzleAPI%2F";
    $submissionsID = $_POST['submission_id'];
    $file = $_POST['selectfile'];//change selectfile with your upload field name
    echo $url.$submissionsID."-".$file;
    ?>
    I did some google searches and tried adding "exec" to the echo command but it didn't work.
    The file can be found at http://www.musclecartees.com/zazzle.php
    This is Zazzle's API documentation page: https://www.zazzle.com/my/associate/create_a_product_api_doc and I believe I sent the email address for the developers at Zazzle in one of my previous posts.
    You know, when this is worked out I was wondering if it wouldn't be too much trouble to ask that my domain name be replaced with in the message thread, only because I've had so many of my ideas "borrowed" over the years and I seem to have hit a good niche market with this one, I'd just like to keep it kind of discreet. And if you can't then maybe delete what I just said. ;-) Thanks.
  • Profile Image

    Answered by jeffest on November 07, 2013 at 04:50 PM
    Okay, I must confess my utter confusion at this point. I set the php file as a webhook but it's still going to the Thank You page so I'm obviously missing something. And yes I am looking at the documentation but I think my brain is too fried right now to make enough sense of it, lol.
  • Profile Image
    JotForm Support

    Answered by EltonCris on November 07, 2013 at 06:01 PM

    @jeffest

    Glad it works. If you'd like to execute it directly on your browser without having to copy and paste the URL, user header instead of echo

    Example:

    <?php

    $url = "YOUR ZAZZLE URL HERE"; //Place your ZAZZLE URL :)

    $submissionsID = $_POST['submission_id'];

    $file = $_POST['selectfile'];//change selectfile with your upload field name

    $mainurl = $url.$submissionsID."-".$file;

    header("location:$mainurl");

    ?>

    Let us know if you need further assistance. Thanks!

  • Profile Image

    Answered by jeffest on November 07, 2013 at 06:40 PM
    Well, I'm baffled again. What you posted should've worked because the previous script was echoing everything including the file name at the end, but now the original script isn't showing the file name and because of that this script is giving me an API error. So it is executing but the file name isn't appended at the end anymore with either one. Why on earth would it have been working before? I cleared out my cache, tried a different browser and a different file with the same results - man this is frustrating. So close - maybe I should just build a new form and start over?
  • Profile Image
    JotForm Support

    Answered by EltonCris on November 07, 2013 at 09:20 PM

    @ jeffest

    No, you don't need to recreate the form. That's fine. 

    After checking your form, I've found out why it's no longer prepopulating the data.

    You forget to enabled back the post data on your form. That's the reason why data isn't captured on the php page.

    Here's a guide:

    1. Click Setup & Embed

    2. Click Preferences

    3. Click Advanced Settings tab

    4. Set Send Post Data to Yes

    I have also made a little adjustment on the PHP script.

    http://pastiebin.com/527c498a1c60e

    I simply removed the mainurl variable and combined then directly. It looks like this on the script above.

    header("location:$url$submissionsID"."-"."$file");

    Here I have a demo that it redirects to the URL: http://form.jotformpro.com/form/33107619815960?

    Let us know if you need further assistance. Thank you!

  • Profile Image

    Answered by jeffest on November 08, 2013 at 04:25 PM
    Woohoo! That worked! Thanks to all of you for your efforts. Now I just gotta redo the interface and figure how to open the API page in a new tab, but I think that was already discussed somewhere in the thread so I'll just have to dig around. Thank you again. =)
  • Profile Image
    JotForm Support

    Answered by ardy0689 on November 08, 2013 at 05:02 PM

    We are glad that you managed to make it work on your end. On behalf of my colleagues and my Support Manager, your welcome. Feel free to post your inquiries on a new thread if you got stucked on something.

    Regards

  • Profile Image

    Answered by jeffest on November 15, 2013 at 06:12 PM
    Hi, I know you wanted me to start a new thread but I'm not
    really sure how I'd even word the title, so I apologize and if you want this in
    a new thread then go ahead and move it.
     
    Thanks to your great support I managed to finish my interface to the Zazzle API which you can see
    here:
    www.musclecartees.com/design-your-own
     
    and it works great except for a few small issues which I'm
    trying to resolve with this new test interface:
    www.musclecartees.com/design-your-own-test
     
    In this test interface I was able to figure out how to open the API in a new
    window by embedding the source code and adding , but
    the "Submit" button on my interface page, which I changed to
    "Try it Now", is opening a blank page with a captcha box which I have
    to fill out before moving forward, and after being clicked the button on my
    interface page is staying at "Please Wait…"
     
    The second problem is that I have five different templates for
    customers to choose from but the way it's working now on the live interface
    page, it would require the customer to re-upload the same file each time to
    preview their image on a different template. Also because there's different
    templates I had to create a different Jotform for each, but because of the way things
    are set up I had to name each one the same name (ZazzleAPI) so that when a file
    is uploaded it will end up in the same directory on my server.
     
    …/custom/ZazzleAPI/{filename}
     
    And I did that because what I'd ideally like to figure out is the following: Is
    it possible for a customer to upload a file, click on the "Try it Now"
    button and have the API page open in another window without having to enter a
    captcha (which I assume it is). Then, what I'd like is to have my interface page reset so that the file name that was just
    uploaded is populated for all the "File Upload" buttons (along with being reset to "Try it Now") so that the customer wouldn't
    have to re-upload the file each time they want to try a different template and my submission page wouldn't be overflowing with duplicates.
    I'm not sure how clear this is or, if you do understand my needs, how much of a challenge it would be, but I do feel there's got to be a way for this to work the way I want it to. Thanks again.
    Jeff
  • Profile Image
    JotForm Support

    Answered by jonathan on November 16, 2013 at 07:03 AM

    Hi Jeff,

    It will be best if you do create a separate thread with the new question you have.

    Click on this link to create the new topic.

    You can just used the same title as this one. 

    --

    Creating variables to pass through Zazzle.com API

    --

    Include also the original thread link in the new thread.
    This one

    https://www.jotform.com/answers/272130-Creating-variables-to-pass-through-Zazzle-com-API#23

    so that we can easily refer to it for background details.

    On the new thread I also suggest you try to break down by details your question and what it is you require that we can help you with. Provide numbered steps if possible.

    And it would help if you can provide screenshot images also. Use this guide on How-to-upload-and-add-screenshots-to-support-forum

    We will attend to it as soon as we can.

     

    Thanks.