Validating a launch request
When a launch request is received, the following actions are typically taken by the tool provider:
- verify that the request is valid (e.g. properly signed)
- check that all the data required is included in the request
- create/update a user account
- create/update a resource link space
- ensure the user has the appropriate permissions for accessing the resource link space
- create a login session for the user
- redirect the user to an appropriate home page
The PHP classes will validate the request and assemble the data recejved into useful objects for your application.
Sample code
Update the link in your VLE to launch the page at http://localhost/celtic/exercises/doLaunch.php. This page will validate the request and display some of the data passed. This provides the basis for an LTI launch script for a real application.
doLaunch.php
<?php // Load LTI classes require_once('LTI_Tool_Provider.php'); $db = new PDO('sqlite:lti-workshop.sqlitedb'); $tool = new LTI_Tool_Provider('doLaunch', $db); $tool->execute(); function doLaunch($tool_provider) { // Get customer ID $consumer_key = $tool_provider->consumer->getKey(); echo "Consumer key = $consumer_key\n\n"; // Get user ID $user_id = $tool_provider->user->getId(); echo "User ID = $user_id\n\n"; // Get resource link ID $resource_link_id = $tool_provider->resource_link->getId(); echo "Resource link ID = $resource_link_id\n\n"; echo "Settings:\n"; var_dump($tool_provider->resource_link->getSettings()); return 'Redirect to ...'; } ?>