From the course: Building APIs in PHP Using the Slim Micro Framework
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Create payloads and response codes for API
From the course: Building APIs in PHP Using the Slim Micro Framework
Create payloads and response codes for API
- [Narrator] Now it's been a long time since we stopped to think about the data we're actually getting back from our API. Since the last time we've done this we've added a ton of functionality with regards to creating and deleting messages, and even uploading files. So let's tackle this in two pieces. First, let's improve creating a message. Originally, when we started creating messages we only had a message ID. So in the payload, itself, we've passed back message ID and a message URI. Well now we can get a little bit more advanced, because, if nothing else, we have more data. So let's go ahead and add our new data. In this case we have an image URL. And the image URL is just simply the URL of the image that we just loaded. So we can say message, image_url. So now when somebody creates a new message for us, the payload, itself, that comes back after successfully creating that message includes the message ID, in case they need to interact with it, the message URI, in case they need to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.