afam4eva Posted February 5, 2012 Share Posted February 5, 2012 I hope I can get help here as I'm not sure if what I need is PHP related. I want to use a domain name API given to me by namecheap on my website. I've never seen an API befoire, so I don't know how to go about it. What I want to know to start with is: Where does the API code go. Is it a PHP page, an XML page or what? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/256463-i-need-help-with-an-api/ Share on other sites More sharing options...
digibucc Posted February 5, 2012 Share Posted February 5, 2012 an api is an "Application Programming Interface", which means it's an interface you can use to get data from them when building applications. we need more info about their api, but in general, you will use their method of requesting info, usually post - and they will return an xml file that can be parsed by simplexml for example, and using that you can output the received info or do what you need. edit: looking at their api page this is the case. you would need to construct a link that looks like this https://api.namecheap.com/xml.response?ApiUser=apiexample&ApiKey=56b4c87ef4fd49cb96d915c0db68194&UserName=apiexample&Command=namecheap.domains.getList&ClientIp=192.168.1.109 the color in red is the command you want to run, change it you'll need to do that in php obviously , to be able to do anything with the info, otherwise it will just show an xml page i did something similar for another site <?php $url = "http://api.jambase.com/search"; $url .= '?band='. str_replace("\\", "", str_replace( ' ', '+', $data["band"])); if (!empty($data["zip"])){$url .= '&zip='. $data["zip"];} if (!empty($data["radius"])){$url .= '&radius='. $data['radius'];} $url .= '&apikey=xxxxxxxxxxxxxxxxx'; //echo $url. '<br>'; // Load the call and capture the XML document returned by API as an object $xml = simplexml_load_file($url); ?> and it will then return an xml object to the $xml variable read the http://php.net/manual/en/book.simplexml.phpsimplexml man page to know how to do what you want with the retrieved info Quote Link to comment https://forums.phpfreaks.com/topic/256463-i-need-help-with-an-api/#findComment-1314762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.