Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 22nd Oct 2012, 11:15 PM   #1
Warrior
 
brentb's Avatar
 
Join Date: 2011
Location: USA
Posts: 755
Thanks: 17
Thanked 177 Times in 118 Posts
Default
What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

I know php pretty well but have never set up an API. I know I know, can't believe I have survived so long. Not a lot of great documentation that I could find that is basic so I can 'get' the concept. But more in depth than API secret then server sends info to server and then back.

What i do know about communicating to other servers is this:

1. You can access other server scripts by just doing <img> or <iframe> to the code with appended variables.

2. You can submit via cURL.

How does it work in API to communicate back and forth? I am pretty sure its not either of these ways.

Also if there is a very simple API for facebook or twitter or something easy for me to learn on, any suggestions appreciated.
brentb is offline  
Unread 23rd Oct 2012, 12:53 AM   #2
I am Legend. Kinda :)
War Room Member
 
tajimd's Avatar
 
Join Date: 2008
Location: Internet
Posts: 53
Thanks: 8
Thanked 15 Times in 12 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

When using img or iframe, what happens is, the other server sends you fully formatted output which you can just plug into your own site.

When using API.. the other server sends the output result in JSON or XML format which you have to then format using your own PHP, HTML and output into your site.

So, if you know PHP then go ahead and learn how to output JSON and XML results in PHP and once you know that then it becomes pretty easy to work with any API.
tajimd is offline  
Unread 23rd Oct 2012, 01:58 AM   #3
Software Product Creator
War Room Member
 
SteveSRS's Avatar
 
Join Date: 2012
Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

IMG and iframe has really nothing to do with API's.

API's can be XML, JSON (as mentioned before) but also plain text, your own protocol, using the full array of webserver commands (GET, POST, PUT, DELETE).

The most simple api setup would be:
www.server.com/api.php?command=getdata

Where you would be using $_GET for data input and just echo data out to reply.
Of course this is NOT the recommended method and you must ALWAYS verify input data and never trust it.

Recommended: JSON-RPC - works awesome!

SteveSRS is offline  
Unread 23rd Oct 2012, 04:39 AM   #4
Hypothetical Paradox
War Room Member
 
eminc's Avatar
 
Join Date: 2011
Location: India
Posts: 82
Thanks: 12
Thanked 20 Times in 19 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Hey,

API works just like normal PHP code, difference being that you can input/output using any other programming language. Mostly conversion tracking and other things are done by Javascript, so people prefer using JSON as one of the methods of passing variables.

You can make api work like this:

1) Let the user get authenticated by putting a request, something like:

http://yoursite.com/api/auth.php?una...&secret=secret

2) at the auth.php file, authenticate them, and set session variables, User's IP and Username and give them a token (a random string ). Store that token in session variable too.

3) For all the other request they make, verify the token, and the IP Address for the request, and get on with the query. Note that you may have to set a time out for their session too

Just kept it simple, you can obviously add some other things to make it more secure

iframes and img tags are just the same, they access the same script, get the same thing done. Some are used for a particular task e.g. iframes for displaying buttons that involve interaction on some other domain(facebook likee, tweet), img tags for pixel tracking etc.


Mohit

The best way to predict future is to create it ― Abraham Lincoln
eminc is offline  
Unread 23rd Oct 2012, 04:52 AM   #5
Active Warrior
 
Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

For APIs CURL is used anyway.

There's a param for CURL curl_setopt:
CURLOPT_RETURNTRANSFER

If this param is set as true, the curl_exec command returns back the output.

Now the API owner decides what format they print data on their side plain text, JSON, XML etc.
viescripts is offline  
Unread 23rd Oct 2012, 07:22 AM   #6
Warrior
 
brentb's Avatar
 
Join Date: 2011
Location: USA
Posts: 755
Thanks: 17
Thanked 177 Times in 118 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

So to request the API I should use cURL to make the request and grab the output, however I should be prepared for a json or xml output?

Thats basically API101 in a nutshell?
brentb is offline  
Unread 23rd Oct 2012, 09:26 AM   #7
VIP Warrior
War Room Member
 
SteveJohnson's Avatar
 
Join Date: 2007
Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Originally Posted by brentb View Post

So to request the API I should use cURL to make the request and grab the output, however I should be prepared for a json or xml output?

Thats basically API101 in a nutshell?
No. That's not API101 in a nutshell.

First, read this: Application programming interface - Wikipedia, the free encyclopedia

You'll see that an API is nothing other than a set of rules that a site sets up in order to allow access to some portion of its stored data or functionality. Nothing more. A site publishes directions on how its API works - you follow those instructions when you're programming whatever it is you're using their data for.

HOW you access that data or functionality is up to the author of the API. Some sites let you make a simple HTTP request to a certain URL using GET: http://somesite.com?param1=all&param2=none

Some make you use POST requests.

Either can be accomplished within your own script by using cURL, if you're using PHP. You make the request, get the response, and do something with it.

The key is, you ALWAYS know what form and structure the response will have, because the sponsoring site has told you in its description of its API. You never have to guess, you never have to 'be prepared for json or xml output'.

Check the Amazon Product Advertising API at https://affiliate-program.amazon.com...tail/main.html, or PayPal's x.com for places to get your feet wet.
SteveJohnson is offline  
Unread 25th Oct 2012, 08:25 AM   #8
Active Warrior
 
Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Originally Posted by brentb View Post

So to request the API I should use cURL to make the request and grab the output, however I should be prepared for a json or xml output?

Thats basically API101 in a nutshell?
yes, this is the basic idea of API.
You post to API via CURL by POST or GET method a series of variables and values: API passphrase, some other data and get back from them the result, then just decode it.

All try to make now API as a set of standards, but all basicly work the same way.
viescripts is offline  
Unread 25th Oct 2012, 08:28 AM   #9
Active Warrior
 
Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Originally Posted by SteveJohnson View Post

No. That's not API101 in a nutshell.

First, read this: Application programming interface - Wikipedia, the free encyclopedia

You'll see that an API is nothing other than a set of rules that a site sets up in order to allow access to some portion of its stored data or functionality. Nothing more. A site publishes directions on how its API works - you follow those instructions when you're programming whatever it is you're using their data for.

HOW you access that data or functionality is up to the author of the API. Some sites let you make a simple HTTP request to a certain URL using GET: http://somesite.com?param1=all&param2=none

Some make you use POST requests.

Either can be accomplished within your own script by using cURL, if you're using PHP. You make the request, get the response, and do something with it.

The key is, you ALWAYS know what form and structure the response will have, because the sponsoring site has told you in its description of its API. You never have to guess, you never have to 'be prepared for json or xml output'.

Check the Amazon Product Advertising API at https://affiliate-program.amazon.com...tail/main.html, or PayPal's x.com for places to get your feet wet.
formally we can call API - any post or get action in our browser window
viescripts is offline  
Unread 25th Oct 2012, 09:42 AM   #10
Social Apps Made Easy
War Room Member
 
FirstSocialApps's Avatar
 
Join Date: 2012
Location: Mooresville, NC
Posts: 913
Thanks: 231
Thanked 259 Times in 213 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Some half correct info here posted by the other users:

API = Application Programmers Interface , in the context of web development its just a set of 'rules' to interact with another site. Nothing more.

FirstSocialApps is offline  
Unread 25th Oct 2012, 02:50 PM   #11
Active Warrior
War Room Member
 
Glen Barnhardt's Avatar
 
Join Date: 2006
Location: USA
Posts: 31
Thanks: 1
Thanked 17 Times in 9 Posts
Default
Re: What the &*%^ API's?
Share on: 
fb share twitter share gplus share more share

Wow, Yes an API is simply a Application Programmers Interface. How it works depends on the site offering the API. The goal often being to receive data and sometimes update.

The reason for an API is to allow programming that interacts with the other systems Site. Google for instance has API's for a number of things.

The Google Maps API allows you to create Maps on your site. You send information about a location and it sends you information back to build the map.

I've worked with API's on Facebook, Twitter, Google, Aweber, PayPal, Authorize.Net, and at this point I can't even remember the rest. But not one of them works exactly the same. So you have to learn how the API on that system works and then create the code to use it.

Some API's can be tested with a browser. These allow for URL parameters to be sent and the data will be returned.

The best thing to do is find the specific API your interested in working on. Then look at the documentation.

Try creating an interface to work with it. When you have problems then post your questions.

Sincerely,
Glen Barnhardt
______________________________________________

[SIGPIC][/SIGPIC]
Glen Barnhardt is offline  
Closed Thread


Bookmarks

Tags
and%, api


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:29 PM.