如何使用OK Tech Web服务使用PHP应用程序登录Moodle?

问题描述 投票:-1回答:1

我想使用OK Tech Web服务的login()函数使用PHP应用程序登录Moodle。

当我登录我的应用程序时,在登录功能中,我编写了以下代码,用于登录OK Tech Web Services的Moodle。

我尝试了两种方法:

1 -

            $postdata = http_build_query(
                array(
                    'username' => 'XXXXXX',
                    'password' => 'XXXXXX',
                    'wsfunction' => 'login',
                    'wsformatout' => 'dump'
                )
            );

            $opts = array('http' =>
                array(
                    'method'  => 'POST',
                    'header'  => 'Content-type: application/x-www-form-urlencoded',
                    'content' => $postdata
                )
            );
            $context  = stream_context_create($opts);

            $result = file_get_contents('http://mymoodleserver/wspp/service_pp2.php', false, $context);

和第二种方法

$xml_user =  simplexml_load_file('http://mymoodleserver/wspp/service_pp2.php?username=XXXXXX&password=XXXXXX&wsfunction=login&wsformatout=dump');

这样我就编写了代码并使用了这个函数。

现在请检查一下。

php moodle
1个回答
2
投票

您可以简单地使用Moodle的登录功能,而不是使用OK Tech Web服务。

© www.soinside.com 2019 - 2024. All rights reserved.