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


How to login in Moodle using PHP Application using OK Tech Web services?

我想使用login() OK Tech Web 服务的功能使用 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');

通过这种方式,我编写了代码并使用了该函数。

现在请检查这一点。

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