thready
asked on
REST APIs and their server implementation
Hi Experts,
I'd like to know what to do with a request like this on the server:
http://www.example.com/services/1
This is asking for info about a service whose id is 1. Great.
Am I missing the name of the PHP page in the URL? I think not because this is how I've seen these REST APIs described - as resources. So if I want to use PHP to implement this rest API call, what do I do on the server side?
Thanks, I hope this question makes sense.
Mike
I'd like to know what to do with a request like this on the server:
http://www.example.com/services/1
This is asking for info about a service whose id is 1. Great.
Am I missing the name of the PHP page in the URL? I think not because this is how I've seen these REST APIs described - as resources. So if I want to use PHP to implement this rest API call, what do I do on the server side?
Thanks, I hope this question makes sense.
Mike
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok.. this is really not what I was hoping for.... Why would everyone preach to use REST APIs and then have to use mod_rewrite... Maybe my URLs *are* supposed to prepend the PHP page...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's just that I've been following a tutorial online that explains that best practices say you should always have this structure, which will make you more scalable, more flexible, more this and that....
GET /photoalbums/italy2012/pho tos/12345. jpg
photoalbums is always a noun, italy2012 is a specific album
photos is always a noun and 12345.jpg is a specific picture...
They do say that you can use search parameters to get at stuff like this:
GET /photoalbums/japan2010/pho tos?page=1 &page_size =25
I'm just trying to learn the best practice way of doing it, and it surprises me that it would introduce the need for rewriting URLs in order to support a best practice... I feel I'm still missing something. Sorry for being hardheaded- I really appreciate your help but I think I might be looking for something more subtle than it's worth. I hope someone sees what I'm getting at here......
GET /photoalbums/italy2012/pho
photoalbums is always a noun, italy2012 is a specific album
photos is always a noun and 12345.jpg is a specific picture...
They do say that you can use search parameters to get at stuff like this:
GET /photoalbums/japan2010/pho
I'm just trying to learn the best practice way of doing it, and it surprises me that it would introduce the need for rewriting URLs in order to support a best practice... I feel I'm still missing something. Sorry for being hardheaded- I really appreciate your help but I think I might be looking for something more subtle than it's worth. I hope someone sees what I'm getting at here......
ASKER
They say that everything is a resource or collection. If you have a collection in a collection, the format is as I wrote above ( collection1/iteminCollecti on1/subcol lection/it emInThatSu bCollectio n. Not sure how much this gives you to follow these guidelines....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad you found a good answer. The integration of the client-side jQuery is hardly necessary for a RESTful API, but it seems to offer a good client interface.
ASKER
It's not the client side part of what this page talks about- it's the mappings they do in php with slim to the functions...
ASKER
Thanks for your answers! :-)
ASKER