Dynamic page results based on user input

thanks for the feedback.

the share / download thing is definitely on my todo.

any tips on how to capture the dynamic rendering, other than taking a screen grab of it?

haven’t even started to research this part yet.

ur gonna say javascript again, aren’t you? :wink:

Not quite sure what you mean. Do you mean the grade and running total for tweeting?

yes, i mean the Your Grade image… if i right click in firefox it offers ‘screen grab’ in the menu

when i select it, i can single out the html element that makes up the image, as so

image

and i can paste it into other apps that understand how to turn that into an image (like twitter or here on PG).

paste doesn’t work in simple text boxes like the url addr bar or notepad.

Well, you can send tweets with PHP using the twitter OAuth. I haven’t done it before, but I think you would have to grab your DOM element (probably using JavaScript :wink: ) and then send it as a post to your server. The script on the server side would then have to negotiate with twitter to send the DOM element out as a tweet. My mind gets cramps thinking about how to set the rest of the tweet up on the client side if they want to add anything. Maybe mock up the twitter interface in a HTML modal, then parse it out and send it to the server? I’m impressed with how far you come so far with this. As they say in the iconic movie ‘The Waterboy’, “You can do it!”

1 Like

thanks, i may just cheat and throw in a modal with instructions on how to take a screen grab…

Ok, so that was a long journey.

But i’ve finally managed to include the “share your score” via twitter function, and i’m pretty pleased with how it came out.

Diving into the details of PRG architecture and all the flame wars about when it applies when it doesn’t apply… made it really hard to figure out WHAT IT IS they were talking about, and HOW to actually do it.

this guy explained like i needed it explained.
PHP - Post / Redirect - Part 2 https://youtu.be/bIkqNHyj25w via @YouTube

I also found a linux utility (open source) called wkhtmltoimage that will render a dynamic html file (with php embedded) at the server end and save it as a .jpg… that was the other half of the battle. The render engine is not fully up to spec but it does a decent job on simple markup and style. It’s supposed to support .css style sheets, but i just cheated and put them inline.

then the 3rd half of battle was coordinating all the files and handoffs i needed to make in order to get those results into a tweet. twitter cards are used to display the dynamic output in the twitter timeline (i was actually surprised that worked, twitter has been flaky)

feel free to take it for a test drive.