Reading data from course URLs

Reading data from course URLs

by Animesh KC -
Number of replies: 0

I have a course from which I have to interpret data for a project using PHP, and the main contents of the course are in links of a form like this: http://localhost/moodle/file.php/6/stuguide/unit1/unit1complete.html

I am unsure how I'd be able to access these links. Using the file_get_contents function didn't work because it prompted a login page every single time the function tried to read the link, regardless of whether I was logged in. I looked through the file API, but I wasn't sure how to read data from these links, since the read file procedure was said to only work for mod/mymodule/* code


the simple extractData function used to read the URLs

I was using a function like the above. I call extractData with urlArray that stores all the desired links of the units for the course. Obviously, it would require some parsing, but I first need it to read the pages properly. 

the login prompt that displays when the function is called

This is the login prompt I get after calling the function. If I do login, it will tell me to 

Is there another way to read this content, or is there a way to get around the login prompt every single iteration?

My moodle version is 3.4.7. The course follows the "topics format", and I am using the Boost theme. 

Average of ratings: -