I built TheReelBox.com to demonstrate an easier way to find nearby movie showtimes than Fandango or Google Movies. (More importantly, it generates demo data for showing off Segment.io.)
It turns out that movie showtime data is difficult to get and the APIs cost a lot of money to use: you have to call Fandango, West World Media, or Tribune Media Services just to discuss access to the API. Obviously I was not going to do this just to throw together a side project.
A Few Caveats about YQL
YQL has complicated request limits. Executing one showtimes query uses about 1 million execution units (50 million maximum per query.) There's also a limit to 10k or 100k requests per day.
Also consider what happens every time you need some showtimes: TheReelBox fires a JSONP to YQL, which requests the appropriate Fandango page, which is then parsed in YQL, converted to JSON and returned to TheReelBox. It's crazy slow. To speed things up I needed a sort of "API Caching Layer". Firebase ended up fitting the bill perfectly. I'll write about that another time.
The online interface for YQL has lots of issues. It's freaking impossible to debug YQL parser problems (you kinda just stare at the code and hope for the best...), and their online console deleted all my files occasionally... but hey, it generally works.
Reverse Engineering the Ticket URL
Fandango provides urls to affiliate advertisers (apply at cj.com) for purchasing tickets, but you can't link to the exact movie+showtime+theater, so the user has to re-select which time and theater they want. I wanted links on TheReelBox to take users to the final purchase page, and this is where things got interesting.
First, I discovered that Google Movies and Movies.com have direct links to the Fandango ticket purchase page - this is special among affiliates.
Here's an example Movies.com referral URL:
The base url is static and simple, but the GET parameters are interesting.
row_count: this changes for every movie, theater and showtime, so I assumed it's a unique reference to the ticket/showtime the user wants to buy.
tid: according to imerchantnetwork.com this is a "Terminal ID" used for card transactions.
mid: for internal Fandango links this changes by movie, so I figured it's a "movie id". Confusingly, imerchantnetwork.com claims this is a "Merchant ID"... dunno.
wssaffid: this parameter is standard in affiliate links, and appears to be a unique ID for each affiliate.
wssac: this parameter is also standard in affiliate links, no clue what it represents.
Can we put together the necessary information to create our own direct checkout links?
It turns out that row_count, tid, and mid are all used by Fandango in their internal urls, so we can snatch these parameters in our YQL parser.
Through the affiliate program you can look at your generated affiliate links to find the wssaffid, and wssac numbers.
So, boom! Yes we can link directly to the purchase page with a little work. Here's an example with TheReelBox affiliate info plugged in:
Now, I had no idea whether this was working or not, and then someone bought a ticket. The commission came through perfectly.
Finally, since you're probably curious: TheReelBox users have clicked through to Fandango and purchased $256.00 worth of tickets, generating $2.10 in commission - 10 cents a pop. Luckily, Fandango won't mail a check until commission hits $50.00. Currently I estimate that the check will arrive on February 9, 2018... I'm stoked :)
This is a follow-up to questions asked on HN when TheReelBox launched http://news.ycombinator.com/item?id=3714509
New discussion is at http://news.ycombinator.com/item?id=4044262