Jump to content

I need help with an API


afam4eva

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/256463-i-need-help-with-an-api/
Share on other sites

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

 

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.