2012-04-06 65 views
2

我使用的PECL庫的OAuth的建設成果LTI服務體簽訂的OAuth XML請求,是否有可能建立一個體簽署的OAuth請求,看起來像:使用OAuth的PECL

POST http://www.imsglobal.org/developers/BLTI/service_handle.php HTTP/1.0 
Host: 127.0.0.1:80 
Content-Length: 757 
Authorization: OAuth realm="",oauth_version="1.0", 
oauth_nonce="29f90c047a44b2ece73d00a09364d49b", 
oauth_timestamp="1313350943",oauth_consumer_key="lmsng.school.edu", 
oauth_body_hash="v%2BxFnmDSHV%2Fj29qhxLwkFILrtPo%3D", 
oauth_signature_method="HMAC-SHA1", 
oauth_signature="8auRpRdPY2KRXUrOyz3HKCs92y8%3D" 
Content-type: application/xml 
<?xml version = "1.0" encoding = "UTF-8"?> 
... more xml data ... 

我試圖使用IMS Global LTI標準接口與Instructure的Canvas LMS進行通信。 Outcomes Service可讓您使用oauth signed xml messages

回答

3

將分數發送回LMS。事實證明,pecl oAuth目前不支持oaut_body_hash。

我結束了使用此谷歌代碼庫http://code.google.com/p/oauth/的OAuth的圖書館和計算機身上有自己:

$bodyHash = base64_encode(sha1($body, TRUE)); // build oauth_body_hash 
$consumer = new \OAuthConsumer($key, $secret); 
$request = \OAuthRequest::from_consumer_and_token($consumer, '', 'POST', $endpoint, array('oauth_body_hash' => $bodyHash)); 
$request->sign_request(new \OAuthSignatureMethod_HMAC_SHA1(), $consumer, ''); 
$header = $request->to_header() . "\r\nContent-Type: application/xml\r\n"; // add content type header