Downloading form PDF from jotform via php script

  • Profile Image
    Asked 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:


    $pdfurl = "$submissionID&formID=$formID";

    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=`*' did not match expected CN=`' 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(***&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:

    Peer certificate CN=`*' did not match expected CN=`'

  • Profile Image
    Answered on October 14, 2016 at 12:23 PM

    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 is expected but is the actual submit URL being used.  If you were previously on a paid account, the submit URL is and it is for Free accounts.  Updating your script to use the Free account submit URL should allow for more consistent delivery. 

  • Profile Image
    Answered on October 14, 2016 at 01:48 PM

    Thanks for your fast input.

    I can see the submit button posts to so i will try using that vs

    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. 

  • Profile Image
    Answered on October 17, 2016 at 01:40 PM was also not working.

    Went with and the PHP warnings stopped and the PDF downloaded to my server (which hasn't been happening for the last 2 weeks).

  • Profile Image
    Answered on October 17, 2016 at 02:26 PM

    Thank you for letting us know.

    Let us know how it works and if the warnings stopped showing.

    Thank you!

  • Profile Image
    Answered on October 21, 2016 at 06:12 PM

    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 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.

  • Profile Image
    Answered on October 22, 2016 at 01:31 AM


    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, 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

    If you also want to get the website URL assigned to you, use this

    There's also a short URL to get the PDF file, this one looks neat :)$submissionID

    If you need further assistance, let us know.

  • Profile Image
    Answered on October 22, 2016 at 01:34 AM

    Sorry, I mean to say this URL for the plant type

    I can see that you've just mentioned it in your post. :)