Create a course in moodle using php - php

I have been a searching a lot on this
I want to create a course using Web service API of moodle.
Things I understood so far are
There is a function named core_course_create_courses
Need to create a access token
I have a code which uses curl class which I dont know how to configure on my server(godaddy domain) hosting
Please someone have done this post code or suggest me some tutorial to follow.

Enable web services in Moodle - https://docs.moodle.org/30/en/Using_web_services
Then read through these instructions for creating a client - https://docs.moodle.org/dev/Creating_a_web_service_client
There is a php example here - https://github.com/moodlehq/sample-ws-clients/tree/master/PHP-REST

Related

How to generate Azure O365 APIs to get user details which we have created on azure portal using php

I am new to AZURE O365 portal, I have created some users in azure portal.
How can I create API in Azure portal to get the user details which I have already created in the portal and are they users enabled or disabled using PHP.
I tried: I have created application and I created secret Id in the portal, then what I have to do, to generate API for user list using php.
please help on it.
Thanks
Sandeep
Not sure if I undestand you correctly: you created some users on the azure portal and you want to get these users using PHP?
Azure has many APIs, they also have an API for getting these users, here is the specification and example code (not in php, but I think still easy to understand):
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
Basically you can access that data using graphql client. There are many graphql libraries for php. But as I skimmed through the docs, you don't really need a library, just a way to create http requests, I recommend Guzzle.
Before you create that php code, I recommend to simply play with the API by using postman or other api client. If it works there, you can start to create the php code.
The code is basically a http POST request (or whatever is specified in the documentation). The request should contain your API tokens in the header, thats all. Data will be provided usually as JSON. Here are some examples how to use guzzle in php for graph.

I want to connect a php class library one server to another

I am creating a php class library and want to place this on my own server and related the application code placed on another server. Now I what I need is to synchronize them ie the class library could be accessed by the application(s) on the other server.
How to provide a solution so that other application(s) could access my library.
There are several ways to access this library, but you can't access it like the other local libraries or classes. The good way is to use web services.
A good solution is to use SOAP. PHP provides good API for SOAP, which enables you to create SOAP server and client very easily.
You will create a SOAP web server at the library end (on the server where the library is placed), and expose all the functions to the web service which you need to access. This is a very good solution and easy to use. You can find a good SOAP in PHP article here
http://www.codewalkers.com/c/a/Miscellaneous/Using-SOAP-with-PHP/
And also read these
https://stackoverflow.com/questions/8657980/how-to-make-web-service-in-php
php web service example
and this
http://www.vankouteren.eu/blog/2009/03/simple-php-soap-example/
Also another way is to use xml and JSON. Please read this good article.
http://davidwalsh.name/web-service-php-mysql-xml-json
Please do more research and ask Mr. Google several times, and you will get a good solution according to your needs.
Hope this will help you.
Thank you
You are trying to include a file from a different domain.
So that's cross domain.
If you want to use the functions via ajax you can use JSONP.

Moodle Integration with a PHP project of mine

I've been developing a project using php that my students use to take quizes (that moodle can't do itself) Now I would like to integrate moodle and my project such that my project authenticates against moodle users and reports grades into a courses gradebook. I've so far been authenticating using direct database reading but I'm very hesitant to do writes to the moodle database. I'm also aware of LTI; I am open to using it but the human readable documentation and any samples are impossible to find. If you could provide me a sample or documentation thats less theory and more applicable for LTI it would be greatly appreciated.
Thanks in advance.
To do this you need to use the Web Services API. You need to setup a web service first, see Using web services. The entire API documentation is available on your Moodle site via Administration > Plugins > Web services > API Documentation.
You need to use moodle's External Tool, which is created precisely for this kind of uses. External tool uses LTI in the background to send user, course, role etc information to an external application and the external application can even send back scores to moodle if configured as a quiz.
Check out : https://docs.moodle.org/23/en/External_tool
You will also have to make your quiz taking app, an LTI provider.
This open source package is out of the box package to create LTI provider in ruby - https://github.com/instructure/ims-lti
There are similar tools in other languages too, but this one is the most polished one.

iOS/Android application with server API's to pass information

I'm working on project for iOS/ Android application that allow user to Register/Login and than create/share and store files to the server and share it with other users.
To meet this purpose i been following this tutorial: http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app but i found its very basic and i need more information before i start working on it.
My question is, how to create an application for example like Path: https://path.com or instagram, that allow apps to sync with server using API's and pass data between server, phone and users without offering Website to users?
Is there any pre-built open source php/mysql API's that we can use for this purpose?
Any brief tutorial that explain steps to do this (since until now i use to work on basic iOS app and need not require any interaction to server and stuff)?
In project im using php/mysql, in my research i found people also advice to use AFnetworking (http://afnetworking.com/) to replace stranded url fetching, any opinion on that?
I'm hoping to have great discussion on this question since there is lot of questions out there on this topic but non have full descriptive answers!
you can create our own server using tomcat and get the path that act as url for you..and there are many third party framework available for parsing or in iphone they have there own using NSJSONSerialization.you can read the detail from this link.
http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html

Making your PHP website into SAML Identity Provider

Story is that I need to make my website act as Identity Provider (read: IDP). Website itself is on Zend platform. Idea is making a IDP controller by which Service Providers (read: SP) contacts IDP. As it must be part of the website, I would need to include some extension, which could be easily used for responding SAML requests from SP.
I have found list of PHP extensions from:
https://wiki.surfnetlabs.nl/display/OSP/RFC+-+OpenSAMLphp,+a+new+PHP+library+for+SAML+2.0+support
All of these extensions have little documentation or are too complex. For example I haven't found a way to use SimpleSamlPHP in my application and also extracting useful code out of it looks very time consuming (which I really don't have anymore). Also I find all of them hard to implement into website.
I have been googling and checking github for days now, trying to find easy way to use some library (right now I'm trying to implement Lasso, which seems reasonable, but unfortunately lacks good examples / information how to use it as IDP).
Any kind of criticism, ideas, help or tutorial/code examples would be useful.
I wrote a guide about how deploy on an open source software (Tiki-wiki) an IdP using simplesamlphp, and how to connect the IdP to google or salesforce. Take a look:
https://github.com/pitbulk/tiki-saml/blob/master/doc/tiki_wiki_as_idp.rst
SimpleSAMLphp seems intimidating at first but it can handle all the SAML responses for you.
Have you looked at creating custom authentication module - http://simplesamlphp.org/docs/stable/simplesamlphp-customauth
You can tie this module to your existing login mechanism pretty easily.
Check out PingFederate and the PHP Integration Kit from Ping Identity. Alternatively there is the Agentless Integration Kit (instead of PHP) which allows you to integrate using a RESTful API call to the PingFed server instead of embedding any PHP libraries.
HTH,
Ian

Categories