Welcome Guest, Not a member yet? Register   Sign In
Writing an API.
#1

[eluser]visua[/eluser]
Hey guys, I've been searching around Google and wiki, and haven't found much about building an API.

Is there any documentation/tutorials on this?

Thanks guys.
#2

[eluser]kgill[/eluser]
There really isn't anything to write about, an API is just a collection of functions that another program can interact with. The only thing you really need to do for one is write documentation, what each function does, what arguments it expects and what it returns. Implementing how the calling program interacts with it is entirely up to you, PHP class, CI controller, SOAP, XMLRPC, whatever - pretty much the only thing that makes an API an API is knowing that if you call X you'll get Y back.
#3

[eluser]visua[/eluser]
kgill,

Thats probably the best explanation on an API i've ever gotten. Thank you.

So, I shall re-construct my question;

I would like to be able to request a the contents of a specific db row, and return it as plain text. What do you think the best way to accomplish this would be? I've never written anything like this, so any help would be appreciated. Once I've written the function that returns the data, what would be the best way to 'use' that data? Javascript?
#4

[eluser]Ben Edmunds[/eluser]
Your question doesn't really make sense to me... What is the end result you wish to accomplish?

[wrong thread, sry]
#5

[eluser]darkhouse[/eluser]
All you need to do is write a controller that has all of your api functions, and have them output the data however you want, xml, etc. The other site that's using the api will need to use cURL or something to post some data (like a key or username or something, as you said you want a specific row) and return the result. It's up to the other site to be able to parse that data and do something with it, but it's nice when an api provides a library to use, or at least examples.
#6

[eluser]robert.dejesica[/eluser]
Hi visua..

Please check this http://lcsd05.cs.tamu.edu/slides/keynote.pdf
#7

[eluser]Phil Sturgeon[/eluser]
Take a look at my REST implementation for CodeIgniter. I gave a talk at EECI2009 which briefly covered its usage along with the use of my REST client library. Both can be found on my GitHub profile (linked in my signature).




Theme © iAndrew 2016 - Forum software by © MyBB