Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For the basics, I suggest using <a href="http://www.php.net/manual/en/curl.examples-basic.php" rel="nofollow">cURL</a> to access resources by HTTP POST.</p> <p>I put this into a function:</p> <pre><code>function api_call($url,$data,$timeout=20) { $response=false; $ch=curl_init($url); curl_setopt_array($ch,array(CURLOPT_RETURNTRANSFER=&gt;true,CURLOPT_NOBODY=&gt;false,CURLOPT_TIMEOUT=&gt;$timeout,CURLOPT_FORBID_REUSE=&gt;1,CURLOPT_FRESH_CONNECT=&gt;1,CURLOPT_POST=&gt;true)); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//this is an array containing the data you're sending them - an associative array describing which call. //data example: //array('operation'=&gt;'user.verify','admin.username'=&gt;'you','admin.password'=&gt;'pass','reseller.id'=&gt;'xxx') $response=curl_exec($ch); $status_code=intval(curl_getinfo($ch,CURLINFO_HTTP_CODE)); curl_close($ch); return array('status'=&gt;$status_code,'url'=&gt;$url,'data'=&gt;$response); } </code></pre> <p>However, you need to supply a URL. Lucanos noted in the comments it is "api.planetdomain.com/servlet/TLDServlet".</p> <p><a href="http://support.planetdomain.com/index.php?_m=knowledgebase&amp;_a=viewarticle&amp;kbarticleid=77" rel="nofollow">http://support.planetdomain.com/index.php?_m=knowledgebase&amp;_a=viewarticle&amp;kbarticleid=77</a></p> <p>by the way, I only use cURL for GET requests, so I might be missing some details on how to do a POST right. I tried to fill it in, though.</p> <p>You ask "How can I run a 10 iteration loop, doing a check if domain is available, if it's response is available, then perform the register command and exit the script (using the code provided in thd documentation)."</p> <p>Well, here's some pseudocode mixed with valid PHP. I don't know the domainplanet API as you know, so this will NOT work as is but it should give you a decent idea about it.</p> <pre><code> for($i=0;$i&lt;10;$i++) { //set up the domain check call $domains=array('futunarifountain.co.uk','megahelicopterunicornassaultlovepageant.ly'); $domain_check_call=array('domain.name'=&gt;$domains[$i]); $domain_info=api_call($dp_base_url,$domain_check_call); $info=json_decode($domain_info,true);//IF they use JSON and not XML or something if($info['domain']['status']=='available') { $register_call=something();//make the API calls to register the domain, similar to the above if($register_call['success']){ exit();/*or whatever*/ } } } </code></pre> <p>Hope that helps get you on the right track. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload