For another site I needed a way to automatically post to a Pinterest board. It’s a WordPress site, but I didn’t want the posting to be based on when a post went live. I needed a way to automatically post whatever the newest post was that hasn’t already been posted. I’ve already done something similar with Facebook, Twitter, and Tumblr; but since there isn’t a public API for Pinterest yet it wasn’t quite as easy.
What I found was a node.js library called pin-it-node that lets you post to Pinterest. Once that was loaded it was a pretty easy jump to write the following little script to take a couple of command line options and post to Pinterest.
So, I added an action to WP cron that fires every day around the same time that finds a post and then calls this script with the right command line options. At least for now, it’s working without a hitch.
If you’re running from the command line, it’ll look something like this.
$ node pin-it.js "Pin Title" "This is a description for the pin" "http://example/image.jpg"
If you’re interested, the board that’s getting filled is here. Each day there are two fonts – one recent and one random – pulled from DailyFont.com and added to the board. And I also put up a quick page to figure out the numeric board ID which you’ll need for this.