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
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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.