📜 ⬆️ ⬇️

Hivext: Web services platform



Hivext


This is a web services platform with a common interface for accessing them from different programming languages. The goal of Hivext is to provide useful web services to developers, to ensure their stable operation and at the same time, ease of implementation in projects. Hivext will help to connect many existing platforms through a single API.

If you want to easily and quickly create web applications, including development for mobile devices, then the platform is a very interesting tool.
')
The previous article is useful to familiarize yourself with the platform, its architecture, goals and objectives. In this article, we continue to publish changes and new services that have been added to the platform recently.


Major changes


Basic Services


check in

Registration of new users in a common database. Used activation system through the mail.
When registering, the required parameters are mailing address and password.

Registration Service Documentation

Identification and Authentication

Authentication of registered users. Features of the service:
Documentation of the Authentication and Authentication Service

Account management

Service management of personal data of the user. The required set of methods is defined:
Account Service Documentation

Application Management

To start developing applications for the platform, the developer needs to:
All service methods are called knowing the application identifier. Without an application identifier, invoking service methods is possible. The application ID can be linked to a domain, IP address or alias (domains and / or IP addresses). Those. using a specific key on other domains / IP is blocked.

Application Service Documentation

In the development of service structures . This service will allow to expand the existing structure of the platform to the needs of their projects.

An example of using services


API Console - a web application operating on the basis of basic services.

An example of using an authentication service


The example is made on JavaScript and implements the functions: authentication, session termination and user identification.

Step 1: We study the documentation and select the necessary functions.

Documentation of the Authentication and Authentication Service

We choose the necessary methods. We need methods: Signin , Signout , CheckSign .
See if there are ready-made customers for this service. We need a client for javascript.

If there is no client service (for the required language), then the method has enough information to call it. For example, for the Signin method, you need to make an HTTP GET request, the parameters are encoded in urlEncoding . Request example:
http://api.hivext.ru/1.0/users/authentication/rest/signin?appid=1dd8d191d38fff45e62564fcf67fdcd6&email=email@email.com&password=12345678

Step 2: We connect the client service

< script src ="http://code.hivext.ru/frameworks/js/core.js" type ="text/javascript" ></ script >
< script src ="http://api.hivext.ru/1.0/users/authentication.js" type ="text/javascript" ></ script >


Step 3: Create the desired application framework

< style > <br> <br>body {<br> font-family: "Lucida Grande", Tahoma, Verdana, Arial, Sans-Serif;<br> font-size: 10pt;<br> color:#333;<br>}<br> <br>.error {<br> border: 1px solid #ff5050;<br> background-color: #ffc5b5;<br> padding: 4px 10px;<br> margin-bottom: 6px;<br> display: none;<br> font-size: 8pt;<br> font-weight: bold;<br>}<br><br> </ style > <br><br> < body onload ="Load()" > <br><br> < div id ="error" class ="error" ></ div > <br> <br> < div id ="signin_block" style ="display: none" > <br> :     < input id ="email" />     <br>:     < input id ="password" type ="password" />     <br> < input id ="signin" value ="Sign In" type ="button" /> <br> </ div > <br> <br> < div id ="signout_block" style ="display: none" > <br> < div id ="welcome_message" /> <br> < input id ="signout" value ="Sign Out" type ="button" /> <br> </ div > <br> <br> </ body > <br><br> * This source code was highlighted with Source Code Highlighter .

Step 4: Install event handlers and implement the necessary logic

// <br> // onload body. <br> // <br><br> function Load() {<br><br> function id(element) { return document .getElementById(element); }<br> function error(result, error) { return "Code: " + result + "<br />Error: " + error;}<br><br> var sAppId = "0123456789ABCDEF0123456789ABCDEF" ; // . <br> var sSession; // . <br><br> // , cookies ( 3rd party cookies) <br> sSession = Cookies.Set( "session" );<br><br> // (Sign In). <br> id( "signin" ).onclick = function () {<br><br> // . <br> if (!id( "email" ).value || !id( "password" ).value) { <br> id( "error" ).innerHTML = " ." ;<br> id( "error" ).style.display = "block" ;<br> return false ;<br> }<br><br> // <br> // . <br> // <br><br> Users.Authentication.Signin(sAppId, id( "email" ).value, id( "password" ).value, function (oResponse) {<br> if (oResponse.result === 0) {<br> // , Sign Out ( ). <br> id( "error" ).style.display = "none" ;<br> id( "signin_block" ).style.display = "none" ;<br> id( "signout_block" ).style.display = "block" ;<br><br> // . . <br> sSession = oResponse.session;<br><br> // ( cookies - 3rd party cookies). <br> Cookies.Set( "session" , sSession);<br><br> } else {<br> // , . <br> id( "error" ).innerHTML = error(oResponse.result, oResponse.error);<br> id( "error" ).style.display = "block" ;<br> }<br> });<br><br> return true ;<br> }<br><br> // (Sign Out). <br> id( "signout" ).onclick = function () {<br><br> // <br> // . <br> // <br><br> Users.Authentication.Signout(sAppId, sSession, function (oResponse) {<br> if (oResponse.result === 0) {<br> // . <br> id( "error" ).style.display = "none" ;<br> id( "signin_block" ).style.display = "block" ;<br> id( "signout_block" ).style.display = "none" ;<br> <br> // , . <br> Cookies.Clear( "session" );<br> } else {<br> id( "error" ).innerHTML = error(oResponse.result, oResponse.error);<br> id( "error" ).style.display = "block" ;<br> }<br> });<br> }<br><br> // <br> // . <br> // <br><br> Users.Authentication.CheckSign(sAppId, sSession, function (oResponse) {<br> if (oResponse.result === 0) {<br> // , , . <br> id( "signin_block" ).style.display = "none" ;<br> id( "signout_block" ).style.display = "block" ;<br> } else {<br> // , . <br> id( "signin_block" ).style.display = "block" ;<br> id( "signout_block" ).style.display = "none" ;<br> }<br> });<br>} <br><br> * This source code was highlighted with Source Code Highlighter .

And here is an example of authentication: http://code.hivext.ru/examples/js/common/sign.html
Login: guest@guest.com , Password: guest

Applications


Platform documentation: doc.hivext.ru
Applications and components: hivext.ru/index.php/components
The source code of examples under the license LGPL3 is uploaded.

Developers


Aleksandrov KM m007 , Ruslan Sinitsky sirus

Upd : If this topic is interesting, but the essence is not completely clear, then we will make a separate article with a couple of schemes and a description of the work.

Source: https://habr.com/ru/post/50771/


All Articles