This article explains the basics of using PHP SDK classes and methods. In this article I’ll use the Comparison API and show how to compare two documents from a GroupDocs account. Find information about other methods in the Swagger explorer.

Requirements

We already know how to install the Fatfree framework and prepare for creating the sample from the previous article. So lets start with the magic.

Sample Creation: Creating the TemplateCreate a template file in the template folder and name it Comparison.htm. This generates a web page with a form for entering the necessary data such as user ID, private key and the file GUIDs for the two files that will be compared. The user can also enter a callback URL. How to get this data you can find out in the documentation.```

You entered: ClientID = {{@userId}} PrivateKey = {{@privateKey}} Source file Id = {{@sourceFileId}} Target file Id = {{@targetFileId}} Call back url = {{@callbackURL}}

The Template Code ExplainedThis code block shows the data the user entered. Here you can see code like this: \{\{@userId\}\}. In the Fatfree framework you must call a variable declared in the controller for the template.```

You entered: ClientID = {{@userId}} PrivateKey = {{@privateKey}} Source file Id = {{@sourceFileId}} Target file Id = {{@targetFileId}} Call back url = {{@callbackURL}} The next step in the template file creates a div block with the form for entering data:

CallbacksLet’s explain some key moments for this code. In the Fatfree framework, the form is creation using a simple HTML code which does not need explaining: everything is as usual. But in the value of the input’s we transfer the value of variables from the controller - \{\{@userId\}\} - in order that the user data stays in the values when the user clicks Make request. Also you can see here the input named CallbackURL. In this field, the user can enter a URL which will be executed by the server after the comparison is done. A callback is something like an action for a form. It can be a PHP file which is triggered by the server. All of these fields are required except for the callbackURL field.

Displaying the Comparison ResultsThe next code block in the template file is:```

Sample Creation: Creating the ControllerGo to the inc_samples folder and create controller file called Comparison.php. This file will contain this code:```