Requirements
- PHP 5.3
- Apache ModRewrite
- PHP Curl extension
- PHP Sockets extension (php_sockets.dll)
- GroupDocs PHP SDK
- composer.phar (Download from http://getcomposer.org/download/ or use the included version.)
- FatFree framework (https://github.com/bcosca/fatfree)
Logic
For security reasons the GroupDocs plugins and services use the User ID and API key to authorize a GroupDocs account from remote plugins. But this method is not comfortable for users which is why the new SDK release added a new method called LoginUser. With this method a user can be authorized in GroupDocs using email and password like in normal account authorization. As you’ve already guessed, this method takes two parameters:- String email
- String password
Implementation
The template file is the same as in the article about two ways of updating files to GroupDocs accounts. Because of this, I will not explain the template file but go straight to the Controller file where all the magic happens. Here is a sample of the code://###Set variables and get POST data F3::set('email', ''); F3::set('password', ''); $email = F3::get('POST["email"]'); $pass = F3::get('POST["password"]'); //Create signer object $signer = new GroupDocsRequestSigner("12345"); //Create apiClient object $apiClient = new APIClient($signer); $sharedapi = new SharedApi($apiClient); //Login and get user info $getUserInfo = $sharedapi->LoginUser($email, $pass);In this code we get POST data from the form where the user enters the email and password for his GroupDocs account. Them we create the GroupDocsRequestSigner and ApiClient objects using “12345” instead of the API key and SharedApi object to get access to the LoginUser method. In response we get the UserInfoResponse object. This object has all the data about the user account. We are interested in the User ID and API key because we need them to work with GroupDocs data in the account. That’s the entire reason we used the LoginUser method: to get these two parameters. We have all the the account data and from this, we can get the User ID and API key like this:
$userId = $getUserInfo->result->user->guid; $apiKey = $getUserInfo->result->user->pkey;

The structure of the UserInfoResponse object