Using PhantomJS or other Web Driver on Userfrosting


#1

Hi I am creating a pdf scheduled email function. If you visit a webpage it will generate a PDF using pdf2html which will then be downloaded and sent over in an email.

I have got this function working exactly as I would like. When I go to my URL the PDF is generated and emailed to my email address.

The problem is the PDF content is generated via JS so you have to physically go to the page for the PDF to be generated. This then become a problem when you would like to schedule this PDF to be sent at the start of every month.

My idea was to use PhantomJS which will go to the webpage (just like a physical person). This would work perfectly in my head.

The problem I have is the page I am visiting is secured via CSRF and calls APIs which require permissions. I have setup a Public API which generates a JWT token giving me access to the portal and my idea was to some how use this in order to get this scheduler working.

I don’t think PhantomJS allows you to add a JWT token to the header which is the main problem, does anyone have an idea of how to get this working or have an idea which may also work?

Thanks
Luke