Connect Server
Connect Server is a super important element of not only Abtitu but also application development world. Connect Server is developed with a concept of computer world that we called it -- WebAPI. WebAPI is a gateway of different servers with different internet resources. There are a lot of internet resources that we can access or use by sending different requests to the APIs such as making credit card payment, accessing the open data of Gov, sending marketing emails or even controlling smart devices.
Usage
Usually, there are 4 common request types for connecting APIs as below, goto API Concept for more details:
- POST - Create or save some new records to the API servers.
- GET - Read the records that storing in the API servers.
- PUT - Update records from the API servers.
- Delete - Delete records from the API servers.
So, how to send the requests to the servers for creating, reading, updating or deleting records? The first question that you will need to ask yourself is where is the server? That means, we need to have the address of the server which you would like to access. And basically, we will call it -- URL. For example, if we would like to get a facebook user info, we will need to access facebook API for reading user records. We all know the URL of facebook is https://www.facebook.com/. However, it's the fancy interface for general users. It's not program/application friendly. Thus, facebook is also provided a program/application firendly interface for developers to access facebook data. The URL is https://graph.facebook.com. If you paste the URL to your browser, you will see an information or a response as below:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "E2P3yniEsrc"
}
}
Congratulations, you are on the right URL of getting facebook data. And, the interface is not fancy as the page that you can see on your daily life. However, it's super common in the development world. This format we call it -- JSON. You can read what JSON is from Wiki, so we won't go deep the topic here. Most of APIs are requested developers to provide an access key or token for accessing the data due to the security reason. Connect Server component is also supported you to pass the token for accessing API servers. That means, you need to grant a permission from facebook.
Furthermore, some APIs allow you to access data/resources without any authorization. An another URL which also provided by facebook -- https://facebook.github.io/react-native/movies.json is a super example. It's an example for getting a dummy movie data.
{
"title": "The Basics - Networking",
"description": "Your app fetched this from a remote endpoint!",
"movies": [
{ "title": "Star Wars", "releaseYear": "1977"},
{ "title": "Back to the Future", "releaseYear": "1985"},
{ "title": "The Matrix", "releaseYear": "1999"},
{ "title": "Inception", "releaseYear": "2010"},
{ "title": "Interstellar", "releaseYear": "2014"}
]
}
Properties
Simply click a gear on the right hand corner of related "Connect Server" component to edit the properties.
Server URL - The address of the server that you want to access.
Type - The action or request that you want to achieve -- Create, Read, Update or Delete.
Auth Method - The standard/approach for authoring your identity. The information should be provided by the server side.
Username - The username to connect server.
Password - The password to connect server.
Content - The form data or query that tells server what you need.
Format - The format of the form data or query that you provided.