Hi guys,

I don't even know where to start, the ideea is that I want to develope an API that responds with certain data, but I don't have a clue for what to look.

The ideea is that there is a panel like google analytics but with no stats, but some info for some users and I want to let them embed this into their pages as a service.
I think that Javascript or iframe, but I really dislike iframes.

Could you please point me for this method so that I know what to look for ? :)

Edited by Szabi Zsoldos

4 Years
Discussion Span
Last Post by diafol

The data you serve will be based on the url (mod rewrite) with possible authentication (e.g. oauth2).

Once you get authentication out of the way deconstruct the url to see what info the user wants.

I sugegst returning data as json. As you know you can do this via json_encode().

quick e.g.


This tells you that the user wants to get data held for user 2367.

So you could have prepared mysqli queries, e.g. for user data and use '2367' in your execution

The returned data should be in array form that you can then format as json. Yopu just echo this.

The client (caller) can use a jQuery jsonp call for example to get this, if they want to use JS. Or use file_get_contents or even cURL (if fgc not possible for them), if they want to use PHP. The call to you is just the url (authentication aside), so it shouldn't matter if they request via RoR, java, asp.net, whatever.

I've really skimmed this topic and possibly made a few assumptions, but Dani is the experts here. She set up the DW API: have a look here for ideas:

My hobby site: http://dw.diafol.org/en/dw-badge/

Where the php call to DW is basically this format (PHP):

$json_array = json_decode(file_get_contents('http://www.daniweb.com/api/members/' . $id . '/'), true); 

Also here: http://dw.diafol.org/en/dw-box/

WHere I use jQuery and oAuth to extract info (based on code provided in Dani's API pages and Pritaeas' explanations (see threads with #daniweb-api tag)



Edited by diafol


Diafol, thank you for your input, this is exactly what i want to do. It will be a small service for photographers like me to verify their dates for clients.
Let me chew your post so i can start working on it! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.