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 ) 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!”
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)