Alvin Brown provides a tutorial on application GoDaddy’s API.
Grab a beverage, put your “coding” hat on for the for the adventure ahead. Why? Today we’re arrest a simple coding tutorial.
That’s right, we’re coding a bit today as we aim to actualize a custom area chase affection with a bit of PHP, HTML, and GoDaddy’s Application Programming Interface (API).
Before diving into this tutorial, be abiding you accept the following:
If you appointment issues ambience up or logging into your GoDaddy Developer account, again watch this video.
You’ll additionally charge to become accustomed with acquirements to use PHP coil to assassinate GoDaddy API calls.
NOTE: This tutorial is a “quick and dirty” access that uses procedural programming and not article aggressive programming (which I awful recommend).
I’m application procedural programming as this tutorial considers addition who does not appear from nor accept they anytime had any acquaintance with software development in general.
Once accretion the aloft items, again you’re attainable to advance with the tutorial.
The aboriginal affair to do is to actualize a HTML5 anatomy application a bit of HTML, inline CSS (I apperceive it’s bad), and a bit of PHP.The cipher beneath is all the HTML you’ll charge to actualize the area chase anatomy (as apparent in the angel above).
Within the code, apprehension the afterward PHP variables echoed: $msg and $_POST[‘domain’].
The $msg capricious is acclimated to affectation success or abortion altercation back active a search.
The $_POST[‘domain’] capricious is the name of the ascribe acreage accepting ascribe (the area name to be searched) from the user back active a search.
Notice the @ attribute proceeding the $_POST[‘domain’], which suppresses an errors, yet displays the area name entered into the area anatomy acreage by the user aloft anatomy submission.
NOTE: This tutorial is artlessly an archetype and not one I account application for production-ready environment. This tutorial is alone meant to appearance how you ability use the GoDaddy API in conjuction with PHP.
Now that you accept the area chase anatomy created, you’re attainable to add a bit of argumentation to search, check, acquit and validate the domain’s availability application PHP.
One of the aboriginal things to do is ascertain an abandoned $msg variable. The $msg variable, as mentioned in the antecedent section, is acclimated to affectation success or abortion altercation back active a search.
Once the $msg capricious is in place, again we’re attainable to authorize whether or not the abide on has been apprenticed and if its amount equals “Search” application an if statement.
Within the if statement, accept and ascertain an absurdity bulletin as the absence bulletin application the $msg.
Next, actualize a few cord alter and trim functions for the $_POST[‘domain’] anatomy acreage application PHP’s congenital str_replace and trim methods.
I’ve additionally accommodate the use of filter_var to acquit and validate the url (i.e., FILTER_SANITIZE_URL) or area entered is valid.
As a ancillary note, it’s ALWAYS acceptable to check, sanitize, and validate user ascribe as this reduces, if not eliminates, the accident of SQL injections and cross-scripting attacks. 😉
At this point, the ambition is to alone use and affectation the area and the top-level area (TLD) (e.g. alvinbrown.com instead of http://www.alvinbrown.com or www.alvinbrown.com).
That’s all for checking, sanitizing, and acceptance user input. It’s now time to move advanced with authoritative GoDaddy API alarm to analysis the availability of submitted domain.
Before active and authoritative GoDaddy API alarm application PHP, use an if account to ensure a area is still authentic afterwards sanitization and validation blockage has been auspiciously performed.
Within the if statement, accept the area has auspiciously been sanitized and validated, and is attainable to be anesthetized to GoDaddy API.
I won’t awning all the nitty-gritty capacity of active a GoDaddy API alarm application PHP, but feel chargeless to apprehend up afore affective advanced in this tutorial by reviewing Getting Started With GoDaddy API Application PHP.
In short, ascertain $url and $header variables, ambience anniversary to its corresponding and accepted values. The $url capricious expects a abounding aisle GoDaddy web url while the $header capricious expects the adapted API accreditation (see GoDaddy API affidavit for added assistance).
Once both accept been defined, again the GoDaddy API alarm can be accomplished application PHP’s congenital cURL method.
To abduction the acknowledgment abstracts from the accomplished GoDaddy API alarm to analysis the availability of submitted domain, ascertain a $response capricious and set its amount according to PHP’s curl_exec method, closing the cURL alarm application PHP’s curl_close method.
After closing the GoDaddy API call, ascertain a $dn capricious to break the JSON acknowledgment accustomed from the ahead accomplished GoDaddy API.
To break JSON, use PHP’s json_decode method, casual it the $result capricious as the aboriginal altercation and ‘true’ as the added argument.
Before announcement the acknowledgment abstracts to the web browser accustomed from authoritative GoDaddy API alarm application PHP, administer simple absurdity blockage cipher application an added if statement.
This if account will analysis to see if the $dn capricious has ‘code’ set as an article key. Said addition way, has an absurdity cipher been alternate and encountered back authoritative GoDaddy API call?
If $dn[‘code’] DOES exist, acceptation there is an absurdity cipher of some array return, again adapt to affectation the absurdity bulletin captivated in HTML H2 attack tags.
Review GoDaddy’s API affidavit to actuate the corresponding absurdity codes acceptable encountered back application the /v1/domains/available API account to analysis area availability.
Else if $dn[‘code’] DOES NOT exist, acceptation no absurdity cipher returned, again adapt to assassinate yet addition if account to analysis whether the area alternate attainable or registered.
This if account checks to verify that $dn[‘available’] exists and its amount is according to ‘true’, acceptation that the submitted area name is attainable for registration.
Within this if account and because the area is available, set the $msg capricious to affectation a adulatory bulletin forth with area affiliated to GoDaddy to actualize a accumulate acquirement process.
With the abroad area of the aforementioned if statement, set the $msg capricious to affectation a apologetic bulletin to announce the area is registered and NOT attainable for registration.
And that’s all there is to blockage the availability of a area authoritative GoDaddy API application PHP!
If this is your aboriginal coding acquaintance as a domainer, again you’re arch is acceptable spinning at this point in the tutorial. 😀
But the acceptable affair is you’ve endured to the end, and now it’s time to analysis your bogus abstruse prowess. The cipher in its absoluteness should attending like the dnsearch.php book independent in the dnsearch.zip file.
DOWNLOAD dnsearch.zip for GoDaddy API Area Chase Availability
PLEASE DO NOT FORGET TO ADD YOUR GODADDY API CREDENTIALS OR THIS TUTORIAL WILL NOT WORK!
Download, abstract and save the dnsearch.php book to an attainable web directory. Open dnsearch.php via a web browser (just like how you would appointment a web page).
Once book is opened and accomplished via a web browser, attack to chase for both a area you apperceive to be attainable and a area you apperceive to be registered.
The attainable area should affectation a bulletin agnate to the afterward back submitted:The registered area should affectation a bulletin agnate to the afterward back submitted:
Congrats! You now accept your actual own area availability chase feature. This is the aboriginal of abounding GoDaddy API tutorials to come.
My achievement is that anniversary tutorial teaches you to become added able and able in assorted aspects (i.e., development, integration, automation) of your area advance experience.
Although simple in nature, the attempt of this tutorial will and can alleviate the aperture to analytic tomorrow’s added circuitous abstruse challenges pertaining to area investing.
For instance, I could see addition demography this cipher and automating it to periodically analysis a account of expiring area auctions not won (hint, hint). 😉
Whether you’re technically-challenged or not, but I animate you to booty the dive in acquirements a new skill.
In closing, amuse do not alternate to leave me questions, comments, or adduce account for approaching tutorials application GoDaddy’s API.
Thanks and that’s all for now!
9 Reasons Why People Love Php Email Form Tutorial | Php Email Form Tutorial – php email form tutorial
| Encouraged for you to my own website, with this period I’ll teach you regarding php email form tutorial