"120988f929-274612", "resource_link_title" => "Weekly Blog", "resource_link_description" => "Each student needs to reflect on the weekly reading. These should be one paragraph long.", "user_id" => "292832126", "roles" => "Instructor", // or Learner "lis_person_name_full" => 'Jane Q. Public', "lis_person_contact_email_primary" => "user@school.edu", "lis_person_sourcedid" => "school.edu:user", "context_id" => "456434513", "context_title" => "Design of Personal Environments", "context_label" => "SI182", ); return $parms; } function validateDescriptor($descriptor) { $xml = new SimpleXMLElement($xmldata); if ( ! $xml ) { echo("Error parsing Descriptor XML\n"); return; } $launch_url = $xml->secure_launch_url[0]; if ( ! $launch_url ) $launch_url = $xml->launch_url[0]; if ( $launch_url ) $launch_url = (string) $launch_url; return $launch_url; } // Parse a descriptor function launchInfo($xmldata) { $xml = new SimpleXMLElement($xmldata); if ( ! $xml ) { echo("Error parsing Descriptor XML\n"); return; } $launch_url = $xml->secure_launch_url[0]; if ( ! $launch_url ) $launch_url = $xml->launch_url[0]; if ( $launch_url ) $launch_url = (string) $launch_url; $custom = array(); if ( $xml->custom[0]->parameter ) foreach ( $xml->custom[0]->parameter as $resource) { $key = (string) $resource['key']; $key = strtolower($key); $nk = ""; for($i=0; $i < strlen($key); $i++) { $ch = substr($key,$i,1); if ( $ch >= "a" && $ch <= "z" ) $nk .= $ch; else if ( $ch >= "0" && $ch <= "9" ) $nk .= $ch; else $nk .= "_"; } $value = (string) $resource; $custom["custom_".$nk] = $value; } return array("launch_url" => $launch_url, "custom" => $custom ) ; } function signParameters($oldparms, $endpoint, $method, $oauth_consumer_key, $oauth_consumer_secret, $submit_text = false, $org_id = false, $org_desc = false) { global $last_base_string; $parms = $oldparms; if ( ! isset($parms["lti_version"]) ) $parms["lti_version"] = "LTI-1p0"; if ( ! isset($parms["lti_message_type"]) ) $parms["lti_message_type"] = "basic-lti-launch-request"; if ( ! isset($parms["oauth_callback"]) ) $parms["oauth_callback"] = "about:blank"; if ( $org_id ) $parms["tool_consumer_instance_guid"] = $org_id; if ( $org_desc ) $parms["tool_consumer_instance_description"] = $org_desc; if ( $submit_text ) $parms["ext_submit"] = $submit_text; $test_token = ''; $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL); $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms); $acc_req->sign_request($hmac_method, $test_consumer, $test_token); // Pass this back up "out of band" for debugging $last_base_string = $acc_req->get_signature_base_string(); $newparms = $acc_req->get_parameters(); return $newparms; } function signOnly($oldparms, $endpoint, $method, $oauth_consumer_key, $oauth_consumer_secret) { global $last_base_string; $parms = $oldparms; $test_token = ''; $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL); $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms); $acc_req->sign_request($hmac_method, $test_consumer, $test_token); // Pass this back up "out of band" for debugging $last_base_string = $acc_req->get_signature_base_string(); $newparms = $acc_req->get_parameters(); return $newparms; } function postLaunchHTML($newparms, $endpoint, $debug=false, $iframeattr=false) { global $last_base_string; $r = "