We’ve added a new category to our homepage: Most Watched Trailers This Week.
For awhile now, I’ve always wanted to display trailers that were popular with our fans. I finally found some time to look into how to call into Google Analytics’ API. Here’s a very good starting point: Google Analytics – Data Feed Query Explorer. After fiddling with the explorer, I got the query that would generate the results I wanted.
The next obstacle appears that I need to authenticate with OAuth in order to execute the query from my webserver. I found this useful tutorial on how to get an OAuth token from Google: Google OAuth for Installed Apps PHP Example. Initially I was getting a weird error that said my site was not registered:
The site “http://hd-trailers.net” has not been registered.
After a quick search, I found the page where I’m suppose to register my website: Manage your domains. Registration was pretty straight forward. For the “Target URL path prefix”, make sure it matches the domain you’ll be requesting the OAuth token from.
After generating the OAuth token and secret, I injected the OAuth token into my request and things worked pretty much immediately.
Hope you enjoy the new category!