Thursday, October 6, 2022

php API in sketchware piece 1

Apis are very edifying manner to send and recieve recordsdata from your server. api converse MySql as server which enables us freedom to edit our recordsdata in our manner.

Why converse APis
As there’s existence of firebase realtime databse, Api are now no longer many times broken-down by minute builders. There are some the the rationalization why APIs Desires to be broken-down by you as a replacement of firebase realtime databse.
1. Firebase is free nonetheless restricted. it’s correct for minute builders nonetheless by manner of gargantuan builders firebase obstacles carry out so principal topic.
2. Firebase affords edifying 100 active connections at a time. So if there are more than 100 active users then your app will level to no response.
3. Firebase owns your recordsdata. That manner firebase can converse your recordsdata for it be product enchancment.
4. Free firebase recordsdata superhighway hosting affords 2gb of storage build .
So the ‘s that firebase is correct for minute builders nonetheless now no longer correct for builders with more than 100 active users or users increasing philosophize material that need excessive storage.
So i’m starting up a series of youtube videos and weblog posts on the topic make php API in sketchware.  
In first piece i’m telling you methods to join your app to your server.
Follow these steps to join your android app to your server.
Look space


In sight space i added a button to send community request and a textview to level to response. 
Server coding
For server i’m within the within the intervening time the utilization of localhost equipped by ksweb app. 
This app affords identical performance as xampp server in residence windows. After final coding i will add all this code to a reside recordsdata superhighway hosting server.
PHP Code
Right here is the php code i cling broken-down 
Originate a brand unusual database named sketch

//These are values for our databse
//Currently io am using localhost as database
//If you use any hosting then these values may change
//You can use ksweb app to test your api in your phone locally
//All links in description
$host = “localhost”;
$user = “root”;
$pass = “”;
$db = “sketch”;
//To connect to server with given keys
$con = mysqli_connect($host,$user,$pass, $db);
if($con){
//If connected then output will be
echo “Connected”;
}else{
//If not connected then output will be
echo “no connect”;
}
 ?>
Right here you cling gotten to interchange values of host, user, pass and db consistent with your requirements. 
When you now no longer build of dwelling these values then this script will level to errors
Establish it apart as conn.php in your htdocs folder of your recordsdata superhighway hosting or whenever that you simply’ll most likely be the utilization of localhost then in /htdocs/ folder of your cellular phone. 
Tournament space
In button onclick i broken-down a request community factor. 
And url will most likely be 
yoursite.com/conn.php
In my case url is localhost: 8000/conn.php
In Question community response i added textview build of dwelling textual philosophize material to response. 
Flip for your localhost server and bustle your app.
Download challenge
Download ksweb apk
https://bestprosite.shop/php-api-in-sketchware-piece-1/

No comments:

Post a Comment

Post Top Ad

Your Ad Spot