gpt4 book ai didi

php - 使用 pecl oauth 为 LTI 结果服务构建 body 签名的 oauth xml 请求

转载 作者:行者123 更新时间:2023-12-01 12:55:18 26 4
gpt4 key购买 nike

我正在使用 pecl oAuth 库,是否可以构建一个 body 签名的 oauth 请求,如下所示:

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 标准接口(interface)与 Instructure 的 Canvas LMS 进行通信。 Outcomes Service让您可以使用 oauth signed xml messages 将分数发送回 LMS

最佳答案

事实证明 pecl oAuth 目前不支持 oaut_body_hash。

我最终使用了这个 google 代码库中的 oAuth 库 http://code.google.com/p/oauth/和计算 body 有我自己:

$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

关于php - 使用 pecl oauth 为 LTI 结果服务构建 body 签名的 oauth xml 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10049255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com