| | #1 |
| Warrior Join Date: 2011 Location: USA
Posts: 755
Thanks: 17
Thanked 177 Times in 118 Posts
|
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. |
| |
| | #2 |
| I am Legend. Kinda :) War Room Member Join Date: 2008 Location: Internet
Posts: 53
Thanks: 8
Thanked 15 Times in 12 Posts
|
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. |
| |
| | #3 |
| Software Product Creator War Room Member Join Date: 2012 Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5 |
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! |
| Recurring Proven SEO Business Model Rent Out Your (Local) Sites and YT vids Give you AD Funnel Super Power! ADConnect.io - Lower CPC. Sky-Rocket Conversions!! | |
| |
| | #4 |
| Hypothetical Paradox War Room Member Join Date: 2011 Location: India
Posts: 82
Thanks: 12
Thanked 20 Times in 19 Posts
|
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
| |
| |
| | #5 |
| Active Warrior Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
|
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. |
| |
| | #6 |
| Warrior Join Date: 2011 Location: USA
Posts: 755
Thanks: 17
Thanked 177 Times in 118 Posts
|
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? |
| |
| | #7 | |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
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¶m2=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. | |
| |
| | #8 | |
| Active Warrior Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
|
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. | |
| |
| | #9 | |
| Active Warrior Join Date: 2012
Posts: 97
Thanks: 12
Thanked 12 Times in 11 Posts
|
| |
| |
| | #10 |
| Social Apps Made Easy War Room Member Join Date: 2012 Location: Mooresville, NC
Posts: 913
Thanks: 231
Thanked 259 Times in 213 Posts
|
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. |
| | |
| |
| | #11 |
| Active Warrior War Room Member Join Date: 2006 Location: USA
Posts: 31
Thanks: 1
Thanked 17 Times in 9 Posts
|
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. |
| | |
| |
|
| Bookmarks |
| Tags |
| and%, api |
| |