sorry, but that's called fetching data from a DB and returning it as json... the key component of a REST API is the use of RESTful urls and i can't spot any in this video... that's without mentioning how "spaghetti code" this example in your video was
LOL...Do you know anything about programming at all? The URL in the code "index.php" if am not mistaken, returns the JSON data fetch. You can now modify how users are to access that data using GET parameters and conditions. The only reason for any API is to return data...and that's exactly what this is about.
@@thedarkthrone4699 you are severely mistaken. do you know anything about programming? REST API's have endpoints (routes) which are redirected to controllers that then access the database. They typically have an MVC architecture. This is just a regular php file returning data.
@@happinin ...thats exactly what it has to be; API's return data. The "endpoint"? The guy made a tutorial on the basics! need something with "endpoints", It's not the basics.
Hi there, Thanks for the tutorial! But what would you do if you had other methods like to update to store records ? Would you declare the database connection object in each ? In my opinion, it would be better to have that object as a property of the class API, and pass it to the constructor when creating the object (dependency injection).
we create api for easy work on the future, Like when we creating car rental web php x mysql with api so when we create car rental app on android, we can call that api, so we don't have to create data manually #cmiiw
Hi, Jon! I made two videos for you here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6fuhZa6OM2k.html I hope this will help you to build your project. Let me know if you have any questions.
sry, Victor, I cant buy you a coffee cause I live in Belarus. Its too hard to use paypal as a payment system :) but the lesson is very excellent... I can understand your eng speech
So, this is the rest API? I thought it was hard, like something different. How about if we send data like picture or file etc. How does it work in rest API?
Dude, do you even know what a RESTful API is? Hint - this ain't it. This is a PHP page that does a MySQL query and returns the results to itself. Not even close. I also have some issues with your coding. Actually, I have a lot of issues with what you are doing.
Hi there, I just wanted to ask how to decode json, so that I can get only one object from the array/database? In other words, how can I output only 'name'? Thank you in advance! I tried this, but it didn't work: $arr = json_decode(json_encode($response), true); echo $arr->name;
Why would you wanna do that using PHP? The whole point of REST APIs is provide a communication channel between frontend and backend. Once the data is retrieved from DB and is presented in JSON format, you can simply handle it on the client-side using JS
you should not do that in the API, take whatever you want in the front end .. however, in this particular example, if you only wanted to output the name .. you could do: return ( json_encode ( $users['name'] );
why do you make a file directly inside of the htdocs folder? I mean you can make a folder called 'Restful API tutorial' and then put the file inside of that folder. Please explain.
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. See more here: en.wikipedia.org/wiki/Representational_state_transfer
is an api that uses http methods to decribe crud operations and usest urls to describe ghe object/resource to modify/read. the api works with json data most of hhe times. for example: GET: /phonebook/contac/123. it returns the contact id 123 from the phonebook
Hi, Sevent! Sorry for not leaving the source code for this tutorial. Please watch this tutorial about how to read and insert data: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6fuhZa6OM2k.html there I have the source code and it is more complex.