Search code examples
phpauthenticationpdfhtml-to-pdf

converting web page to pdf in protected members area with pdfmyurl


I'm using the pdfmyurl api to convert web pages to PDF. This works fine for all pages on my website, which are not in the members area. My members area requires a user to log in first.

According to the documentation (http://pdfmyurl.com/html-to-pdf-api#secure) I should be able to pass form fields so their converter can access the page. However when I try this, I still get a PDF of the login page.

My login form (http://members.mysite.com/login.php) has the following HTML:

<form class="form-horizontal" id="memberlogin" action="checkpass.php" method="post">
<div class="control-group">
    <label class="control-label" for="user">Username:</label>
    <div class="controls">
        <input name="user" id="user" required>
    </div>
</div>
<div class="control-group">
    <label class="control-label" for="password">Password:</label>
    <div class="controls">
        <input type="password" id="password" name="password" required>
    </div>
</div>
<div class="form-actions">
    <button type="submit" class="btn btn-primary">Sign in</button>
</div>
</form>

And in the checkpass.php script I only check for the values of user and password.

I'm using the following API call:

http://pdfmyurl.com/api?license=mylicense&url=http://members.mysite.com/mypage.php&form_url=http://members.site.com/login.php&form_fields[user]=username&form_fields[password]=password

I'm confident the password for the user is correct as I can manually log in. I'm pretty sure this is also how I should pass an array over HTTP GET.

Any ideas?


Solution

  • Your form page is http://members.mysite.com/login.php, but you check the login parameters at http://members.site.com/checkpass.php

    I think PDFmyURL will need to pass the login parameters to http://members.site.com/checkpass.php, because that's where you check them.

    Try the following API call to do this

    http://pdfmyurl.com/api?license=mylicense&url=http://members.mysite.com/mypage.php&form_url=http://members.site.com/checkpass.php&form_fields[user]=username&form_fields[password]=password
    

    Other than this you must check server logs to find problems with authentication.