- 1 Web Integration Developer's Guide
- 2 Part 1: Letting users select a license
- 3 Part 2: Processing and Storage of license information
- 4 Part 3: Display of license information
Web Integration Developer's Guide
Integrating Creative Commons licenses into your web application
While Creative Commons offers a range of license choices and public domain options direct from its license page, if you have created an application or built a website that allow people to contribute works you may prefer to integrate the license engine directly into your site or application. This guide serves to explain all the steps necessary and options available for integrating Creative Commons into your software.
This guide is generally split into three parts:
- Part 1: Letting users select a license
- Part 2: Processing and Storage of license information
- Part 3: Display of license information
Part 1: Letting users select a license
Whether your software is a website or a downloadable application, the first step to integrating Creative Commons licenses is letting users select a license directly from your software. The process involves loading a simplified Creative Commons license interface from within a popup window, embedded into your website, or launched from an HTML window control in your application. URL variables are read into the page and are appended when complete, allowing data to be extracted from the process and passed through it.
The remote license engine application
The heart of the process is running the remote license interface which is available at this URL:
The full set of URL variables available are as follows:
partner (required): The name of your application or site, used for tracking usage at Creative Commons. Any descriptive name can be added here.
exit_url (required): The return URL on your application that will load after a user selects a license and will contain appended variables in the URL that your software will need to read.
Your exit_url must include "license_url=[license_url]" and may optionally include the license_name=[license_name], license_button=[license_button], and deed_url=[deed_url] variables. Explanation of each:
license_url: URL for the selected license. Link to this URL in the licensed page. Example: http://creativecommons.org/licenses/by/2.0/
license_name: Pretty name for the selected license. Example: Attribution
license_button: URL for the image corresponding to the selected license, useful for displaying on a licensed page. Example: http://creativecommons.org/images/public/somerights20.gif
deed_url: URL for the deed corresponding to the selected license. Usually this will be identical to the value of license_url, unless a "branded" license is selected. Note that even if deed_url is different than license_url, is is still valid to use the URL specified by license_url, as both will point to the same legal code. If you want to support this feature, link to the deed_url in the licensed page. Example: http://creativecommons.org/licenses/by-nc-nd/2.0/deed-music
A sample exit URL would be:
The license engine will replace the license_url, license_name, license_button, and deed_url variables with proper variables once a user has chosen a license (more on this in Part 2).
Note that your exit URL can carry your application's URL variables into and out of the license application by URL escaping within your exit URL, for example:
The above example will let your application know that a userID of 42 that submitted a user-work titled foo.jpg selected a specific license on exit of the license engine.
If you want to maintain state but do not wish to pass data through the URL (e.g., for reasons of privacy or data size), consider saving the data in a user cookie (which will only be sent to your site, not creativecommons.org), save the data in a file or database and save a lookup key in a cookie or pass the lookup key via the URL, or use the popup or iframe methods (see below), which do not require the user to "leave" your form.
URL of a Cascading Style Sheet (CSS) file to customize the layout, look, and feel of the license questions. View source on the license engine to see the ID and classes available to be styled.
partner_icon_url (optional): if you'd like a custom image displayed at the top of the license application, add the image's URL in this variable.
The following enable choosing licenses ported to the copyright law of specific legal jurisdictions. See the [iCommons project] for more information.
jurisdiction (optional): Choose licenses of specified jurisdiction. With jurisdiction_choose on, sets pre-selected jurisdiction. Currently supported jurisdictions: at, au, be, br, ca, de, es, fi, fr, hr, it, jp, kr, nl, tw.
jurisdiction_choose (optional): If set to '1', user will be given a list of jurisdictions to choose from.
Invoking the remote license engine from your application
Once you have figured out the appropriate variables that will be fed into and out of the remote license engine, you need to invoke it from your website or application.
There are a few basic ways to accomplish this task:
- Popup window launched from your website
- Redirect from your website to license engine
- IFRAME embedded within your website
- Launched via HTML control within your desktop application
Popup window launched from your website
Redirect from your website to license page
This option does not use popup windows of any kind and instead you leave the site you originated from, pick your license, then return to the site with your selection info for the site to decifer. Sites using this method would need to parse the URL variables within the return URL.
IFRAME embedded within your website
For those that do not want to use popup windows, have an audience using version 5.0 web browsers and up, and would like to keep the license selection within their application, an IFRAME can be used much like the popup. Sites using this method would embed the question form into their page, and upon completion, pass variables between the IFRAME and surrounding page.
Launched via HTML control within your desktop application
For desktop applications this method would essentially mimic the popup window code, but instead use a native HTML control within your application. On Windows, visual basic and visual C++ applications have access to an Internet Explorer HTML control that can be launched from within your application. For Mac programmers, OS X offers webcore controls that use Safari as a native browser environment from within your application.
Part 2: Processing and Storage of license information
Once users of your website and application have the ability to select a license, the next step is processing the results of their selection. As mentioned in the previous section, the exit_url is the place on your server that users will return to. Once loaded, the data in the URL will need to be parsed. A exit URL result is shown below:
Depending on your web application's server technology, you'll have to parse data from the URL as needed. From the above url, the following data points can be found:
If you had any additional embedded URL variables specific to your application, you will want to parse those out as well. The exact method and code used to read URL variables will depend on your website/application's language of choice and the syntax of that language.
This data can be used in several places within an application. A well-written application will display a user's choice by using the license_name variable as confirmation, such as "You selected the Attribution-Noncommercial license for your uploaded work." You will likely want to store the license_url and license_code variables within your application, most likely in database filed associated with contributions. Again, the exact method and code used to store license information will depend on your configuration, setup, and storage options.
Part 3: Display of license information
The final step to incorporating Creative Commons licensing into your website or application will be the display and expression of license information to other users. For a typical site, we'll need to output some HTML and some RDF (Resource Description Framework) within the HTML. You can use a service at creativecommons.org to generate HTML with RDF for you, or you may create the HTML with RDF yourself.
Request HTML Output for licensed works
Invoke http://creativecomons.org/license/get-html? with information about the license chosen and licensed work. A chunk of HTML that you can include in a web page will be returned. The following data may be passed in:
license_url: Example: http://creativecommons.org/license/by/2.0/
title: Example: A Happy Book
creator: Example: John Smith
copyright_holder: Example: J. Smith Publishing
copyright_year: Example: 2004
description: Example: A short book this is happy, but won't necessarily make you so.
format: Can be one of text, audio, video, image, or interactive.
work_url: If not set, RDF will refer to the page it is included in. Usually this is desired, and work_url should not be specified.
source_work_url: URL for work derived from, if any. Example: http://example.com/jsmith/a_sad_book.html
The following is a complete get-html request using the above values:
If you only want RDF metadata, invoke get-rdf instead of get-html, using the same data.