The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

test_cgi.pl

DESCRIPTION

This is an incredibly simple (and awful) script to show new programmers the OAuth steps required to connect to LOVEFiLM. Please use it as a guide only as programming style has moved on since the 90's, however it does keep the dependancies down.

Also, it will only work for one user.

RUNNING

Having a checkout/download version of the code, I setup apache to have a virtual server with its cgi-bin set like this

    ScriptAlias /cgi-bin/ /the/full/path/WWW-Lovefilm-API/examples

The lib dir is at /the/full/path/WWW-Lovefilm-API/lib, and the required package WWW::Lovefilm::API can be found in there. Hence you don't have to install the package to run it since it is relative and it will be found.

Make sure "vars_tokenless.inc" in the examples directory has your consumer_key and consumer_secret set for your app.

INTERNAL FUNCTIONS

_store

This is a cheap way of storing state when the user gets redirected.

_append

This appends any new key values onto the existing state.

_read

return a hash of representing the stored state

_redirect

Assume the user has accepted a use signup, hence get the access_token, store it, then display the titles they have at home.

Create a link for the user to click on that will take them to the LOVEFiLM site. In the link is the oauth_token (request token) which we asked the LOVEFiLM API for first, hence when the user goes to their website they know our app sent them.

_user_logged_in_page

This function will only work if the user has given permission to your app to access your account at LOVEFiLM.

_get_artwork_href

The images for a given film (title) are split into different directories so we can't construct a URL by just knowing the ID of the title.

This function performs an API call to get the href of the correct image size.