I tried to make script that editing google spreadsheets. But documentation it's not enough to understand how exactly work API. I made registration in API Manager and I downloaded the json file. Could you give me some examples how I can edit document in google drive? Thanks
You can use Google Realtime API, it provides collaboration as a service for files in Google Drive via the use of operational transforms. The API is a JavaScript library hosted by Google that provides collaborative objects, events, and methods for creating collaborative applications.
Realtime API data model may change as a result of edits that were made by someone other than the current user. Realtime data models are "eventually consistent." That means that if all collaborators stop editing, eventually everyone will see the same data model.
Applications where multiple people need to edit the same data simultaneously. Document editors are excellent examples of this kind of application. The Realtime API handles all aspects of data transmission, storage, and conflict resolution when multiple users are editing a file.
For scripting, use Class DocumentApp, the document service creates and opens Documents that can be edited. Documents may be opened or created using DocumentApp.
// Open a document by ID.
var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE');
// Create and open a document.
doc = DocumentApp.create('Document Name');
Here's a documentation how to update drive files: https://developers.google.com/drive/v2/reference/files/update
Related
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 have a small site/web application where registered users can see some files that I periodically prepare for them; I store these files in separate directories and every user can only see and download their own files.
Now, I'm moving these directories to Google Drive and I would keep functionalities like file listing and downloading.
Reading the official docs I found some interesting examples about file download/upload, but all of them talk about authorization that user must give in order to access to their Drive and this is not what I'm looking for, I don't want access to their Drive!
As I can see, the doc is not contempling the case that someone may want to give (read-only) access to own Drive. But maybe I'm missing something...
Basically, I need the list of files on my Drive account and, if requested, a way to download one (or more). The only one that has the auth to Drive account is my server, users will send request from it.
Is it possible? I think yes, but I can't find any docs about that. How can I authorize my server?
I think you're looking for the Using OAuth 2.0 for Web Server Applications where you'll be using service accounts to achieve your goal.
"This document explains how web server applications use the Google API
Client Library for PHP to implement OAuth 2.0 authorization to access
Google APIs. OAuth 2.0 allows users to share specific data with an
application while keeping their usernames, passwords, and other
information private. For example, an application can use OAuth 2.0 to
obtain permission from users to store files in their Google Drives."
The snippets are in PHP too, so it works in your favor.
Is it really possible to directly edit content of a spreadsheet that is located on some Google Drive account from, lets say PHP application?
Is there an API available with granular operations or do I need to download/edit/upload the whole document every time?
Is it also possible to call my script via HTTP when changes are made to this document by user?
Is there any examples of such functionality in PHP or similar technology?
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.
I have an application which handles some data. Now i want to make the data available throughout a php api (something like zend_gdata for google) so my application's users can handle the data from my application in their own applications on an other host.
Is this possible? Can someone hook me up whith some literature or ideas?
This has been written about on numerous occasions. Here is some reading material:
Creating a REST API with PHP
How to Add an API to your Web Service