Skip to content
 
Add note
 

Be confident, just an easy cgi coding

  • Print out all the POST parameters sent from Canvas(sample)

  • Our script to output:

For LTI plugin in richtext editor

change window location to Canvas specified returnUrl with parameters of the iframe ( Possible Redirect Parameters )


for LTI as a tool page( TALIS reading list, PIAZZA )

Some tips

  • Skim read LTI and oAuth specification

  • oauth 1 signature verification:

base_string:
percent encoding POST&yourCgiURL&normalized_parameters

  • use shared secret&token to HMAC-SHA1( base_string ) and generate the signature.

  • LTI Signature Verifier

https://lti-tool-provider.herokuapp.com/tool_config.xml?signature_proxy_test=1

  • Update action: parameter[ "text" ]  the selected iframe html code. 

  • For LTI plugin: add "text" field to your parameter if not exist.

$authorization = "Authorization: Bearer ". $current_token; function getCanvasAPIcurl($authorization, $url){ //// Get cURL resource $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt($curl, CURLOPT_URL,$url); //curl_setopt($curl, CURLOPT_PROXY, $_SESSION['proxy']); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', $authorization )); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); //curl_setopt($curl, CURLOPT_HTTPGET, true); // Send the request & save response to $resp $data = curl_exec($curl); $info = curl_getinfo($curl); if(curl_errno($curl) !=0){ echo "error numbers:". curl_errno($curl) . "
"; echo "error message:". curl_error($curl) . "
"; echo '
Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; curl_close($curl); exit(); } // Close request to clear up some resources curl_close($curl); }
Edit page