Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP卷曲和黑板学习-数据不正确。。。。prolog中不允许POX数据内容_Php_Xml_Curl_Oauth_Blackboard - Fatal编程技术网

PHP卷曲和黑板学习-数据不正确。。。。prolog中不允许POX数据内容

PHP卷曲和黑板学习-数据不正确。。。。prolog中不允许POX数据内容,php,xml,curl,oauth,blackboard,Php,Xml,Curl,Oauth,Blackboard,当我试图使用PHP cURL将此XML文档发布到Blackboard Learn LIS时,我遇到了这个错误。我正在使用simplexml检查XML,以确保其格式正确,所以这不是问题所在。我还检查了XML文档,以确保没有附加任何BOM表数据。我已经在十六进制编辑器中打开了它,以确保这一点 我在这个问题上完全被难住了,而且我没有办法查阅黑板日志 PHP: envelope.php中的XML: <?xml version="1.0" encoding="UTF-8"?> <imsx

当我试图使用PHP cURL将此XML文档发布到Blackboard Learn LIS时,我遇到了这个错误。我正在使用simplexml检查XML,以确保其格式正确,所以这不是问题所在。我还检查了XML文档,以确保没有附加任何BOM表数据。我已经在十六进制编辑器中打开了它,以确保这一点

我在这个问题上完全被难住了,而且我没有办法查阅黑板日志

PHP:

envelope.php中的XML:

<?xml version="1.0" encoding="UTF-8"?>
<imsx_POXEnvelopeRequest xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
    <imsx_POXHeader>
            <imsx_POXRequestHeaderInfo>
                    <imsx_version>V1.0</imsx_version>
                    <imsx_messageIdentifier>53e4657ec1499</imsx_messageIdentifier>
            </imsx_POXRequestHeaderInfo>
    </imsx_POXHeader>
    <imsx_POXBody>
            <replaceResultRequest>
                    <resultRecord>
                            <sourcedGUID>
                                    <sourcedId>bbgc15659375gi290156</sourcedId>
                            </sourcedGUID>
                            <result>
                                    <resultScore>
                                            <language>en-us</language>
                                            <textString>0.7</textString>
                                    </resultScore>
                            </result>
                    </resultRecord>
            </replaceResultRequest>
    </imsx_POXBody>
</imsx_POXEnvelopeRequest>   
在cURL请求期间解析后浏览器中的XML输出:

include("xml/envelope.php"); $xml_length = strlen($xml); $url = $this->lis_outcome_service_url; $bodyHash = base64_encode(sha1($xml, TRUE)); // build oauth_body_hash $consumer = new OAuthConsumer($key, $secret); $request = OAuthRequest::from_consumer_and_token($consumer, '', 'POST', $url, array('oauth_body_hash' => $bodyHash) ); $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, ''); $header .= $request->to_header(); // add content type header $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array("POST http://your-tools-url-here.edu.au HTTP/1.0", "Content-Length: $xml_length", $header, "Content-Type: application/xml")); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch);
由于关于如何在LTI中实现这一点的详细信息太少,我在下面发布了我的解决方案。这是我在Blackboard的Edugage论坛上添加的内容的副本,但为了让它进入公共领域,我把它放在这里。我希望它能帮助其他试图实现LTI工具的人

下面是如何使用PHP cURL传回成绩,envelope.PHP文件的内容应该遵循在中找到的XML。cURL请求构造headerand,然后在其下方添加XML主体。 请注意,envelope.php文件包含以下格式的$xml变量,您显然需要添加自己的$id,并使用变量等设置等级:

使用cURL通过成绩的PHP代码:

<?xml version="1.0" encoding="UTF-8"?>
<imsx_POXEnvelopeRequest xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
    <imsx_POXHeader>
            <imsx_POXRequestHeaderInfo>
                    <imsx_version>V1.0</imsx_version>
                    <imsx_messageIdentifier>53e4657ec1499</imsx_messageIdentifier>
            </imsx_POXRequestHeaderInfo>
    </imsx_POXHeader>
    <imsx_POXBody>
            <replaceResultRequest>
                    <resultRecord>
                            <sourcedGUID>
                                    <sourcedId>bbgc15659375gi290156</sourcedId>
                            </sourcedGUID>
                            <result>
                                    <resultScore>
                                            <language>en-us</language>
                                            <textString>0.7</textString>
                                    </resultScore>
                            </result>
                    </resultRecord>
            </replaceResultRequest>
    </imsx_POXBody>
</imsx_POXEnvelopeRequest>   
include("xml/envelope.php"); $xml_length = strlen($xml); $url = $this->lis_outcome_service_url; $bodyHash = base64_encode(sha1($xml, TRUE)); // build oauth_body_hash $consumer = new OAuthConsumer($key, $secret); $request = OAuthRequest::from_consumer_and_token($consumer, '', 'POST', $url, array('oauth_body_hash' => $bodyHash) ); $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, ''); $header .= $request->to_header(); // add content type header $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array("POST http://your-tools-url-here.edu.au HTTP/1.0", "Content-Length: $xml_length", $header, "Content-Type: application/xml")); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch);