JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
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.
Downloading form PDF from jotform via php scriptAsked by krakerjak on October 14, 2016 at 11:21 AM
I am using PHP to download the pdf form each time a form is submitted using a webhook to notify of a new submission and then PHP code to grab the new PDF of the specific submission using the url provided in your Jotform FAQ:
This has been working great for the past 7 months. The problem I have seen over the last month with this method is that about 50% of new submissions fail to successfully download the PDF from Jotform. The php error log is catching each of these failed download attempts as below:
PHP Warning: file_get_contents(): Peer certificate CN=`*.jotform.com' did not match expected CN=`submit.jotformpro.com' in /home/****/functions.php on line 159 PHP Warning: file_get_contents(): Failed to enable crypto in /home/****/functions.php on line 159 PHP Warning: file_get_contents(https://submit.jotformpro.com/server.php?action=getSubmissionPDF&sid=***&formID=***): failed to open stream: operation failed in /home/****/functions.php on line 159
Is there a new URL to use for downloading PDF forms? I have been getting these PHP warnings since mid August and about 50% of the time the PDF fails to download. Only 100 of 200 approx new submissions since mid august have failed. This section of the warning leads me to believe something changed and there is maybe a new URL to use for downloading PDF submissions:
The only potential issue I can see is that your account is a Free account but is using the paid account submit URL to download the PDF. Check the submit URL from this link:
This should be the proper submit URL for your form. It looks like the error is showing jotformpro.com is expected but jotform.com is the actual submit URL being used. If you were previously on a paid account, the submit URL is jotformpro.com and it is jotform.com for Free accounts. Updating your script to use the Free account submit URL should allow for more consistent delivery.
Thanks for your fast input.
I can see the submit button posts to submit.jotform.ca so i will try using that vs submit.jotformpro.com
A quick test with my formID and a random submission id results in a downloaded PDF. So far so good, ill let that go for a week and see if get any of the php warnings again.
submit.jotform.ca was also not working.
Went with submit.jotform.com and the PHP warnings stopped and the PDF downloaded to my server (which hasn't been happening for the last 2 weeks).
Thank you for letting us know.
Let us know how it works and if the warnings stopped showing.
In the last week I have had 21 new submissions and all have downloaded ok!!!
I would call this fixed.
This poses a new question: If I were to get a subscription would I break my automated PDF grabbing system again because the replying CN would go back to submit.jotformpro.com and PHP's file_get_contents() would fail due to the CN not matching?
If the API has a way of telling if you have a free or paid sub I could work around it.
**Did some digging in the API and realized -- GET user/settings -- will tell me what type of account i currently hold and could adjust accordingly.
Great! Glad it worked for you now.
As far as I know, downloading the PDF file does not actually require specific URL. For as long as it's non-EU URL, it should work fine. You can also use the default domain www.jotform.com, it should work. However, like what my colleague has said, we always recommend using the domain name assigned to you to as it may perform better on your location.
Regarding on getting the plan type, use this endpoint http://api.jotform.com/docs/#system-plan-planName
If you also want to get the website URL assigned to you, use this http://api.jotform.com/docs/#user
There's also a short URL to get the PDF file, this one looks neat :)
If you need further assistance, let us know.
Sorry, I mean to say this URL for the plant type http://api.jotform.com/docs/#user-settings.
I can see that you've just mentioned it in your post. :)