Web Hosting Talk







View Full Version : Whois Sc XML API Partner Question.


Double Tap
11-01-2005, 05:27 PM
Any one ever become a XML API Partner?

this allows you to search for a domain name from you own website, you can use the popular name_spinner, search explorer, and a few other applications.


Basically my question is how do you get it to work. from the manual they provide i am not sure if i have to create the xml application or if i have to just submit the query and the Api sends it to my page? i am confused.. help would be greatly appreciative.

Burhan
11-02-2005, 03:10 AM
I am not a XML API Partner, but generally this process goes as follows:

1. You send them a request using their published parameters.
2. You get a response back in XML format
3. You parse this response and display the result as you prefer.

The process is just as if you were to browse a page -- your 'request' is the URL, the 'response' is what you see on the browser. Essentially, this API is a way to do the above interaction in a precise, documented manner -- and to return the results to you in a format that is easy for you to parse and then display as you like.

For whois specifically, you can find an example of their request and response at this page (http://www.whois.sc/info/xml-partners/api23.html) (their API reference).

Double Tap
11-02-2005, 02:21 PM
Thanks i didn't know if i had to create the xml page to send or if i had to submit a get method, and have them respond with an xml formatted page.

i read their reference multiple times and i wasn't clear on many things.

If i send them the request from the submit butten how does my page recive the responce from the site. Instead of the user being direceted to the engine.whoisapi/ page?

I am a still really new at php, i guess.

Burhan
11-02-2005, 02:47 PM
If you simply use a form on the website, then the user will be redirected to whois.sc and then get the XML response displayed in their browser. Not something you waht.

What you want to do instead is write a PHP script that takes a request from a user for a lookup (this would be the result of a form submit).

Your script then format's the user's request to the format that is required by whois.sc using their API documentation.

Your php script then sends a request and accepts a response.

It then parses the response, and displays the final result to the user (the browser). This entire you <-> whois.sc interaction is transparent to the user. They will never leave your site.

I hope this makes it clear :)

Double Tap
11-02-2005, 02:56 PM
man you are awsome thanks for the help

Double Tap
11-03-2005, 05:45 PM
ok i created a script that request the information from the engine.whois.api.

in return i store the responce in an array. The array looks like this:

<?xml version="1.0" encoding="iso-8859-1"?>Array
(
[0] => HTTP/1.1 200 OK

[1] => Date: Thu, 03 Nov 2005 21:31:53 GMT

[2] => Server: Apache/1.3.29 (Unix) mod_perl/1.29 PHP/4.3.10 mod_ssl/2.8.16 OpenSSL/0.9.7c

[3] => X-Powered-By: PHP/4.3.10

[4] => Connection: close

[5] => Transfer-Encoding: chunked

[6] => Content-Type: text/html

[7] =>

[8] => 7AB

[9] => <?xml version="1.0" encoding="utf-8" ?>

[10] => <whoisapi>

[11] => <application>
[12] => <appname>name_spinner</appname>

[13] => <version>2</version>

[14] => <partner>--my username--</partner>

[15] => <key>--My aPi Key--</key>
[16] => <customer_ip>--myip--</customer_ip>

[17] => <engine>marge</engine>

[18] => <spork>bart</spork>

[19] => </application>
[20] => <request>

[21] => <q>americanparadox</q>

[22] => <rows>20</rows>

[23] => <adult>auto</adult>
[24] => <bc>0</bc>

[25] => </request>

[26] => <response>

[27] => <extn>COM|NET|ORG|INFO|BIZ|US</extn>
[28] => <querytime>0.01664</querytime>

[29] => <totaltime>2.51186</totaltime>

[30] => <e>

[31] => <e_n>americanparadox</e_n>
[32] => <e_s>xxqqqq</e_s>

[33] => </e>

[34] => <d>

[35] => <id>1</id>
[36] => <n>evilparadox</n>

[37] => <s>qqqqqq</s>

[38] => </d>

[39] => <d>
[40] => <id>2</id>

[41] => <n>metalparadox</n>

[42] => <s>qqqqqq</s>

[43] => </d>
[44] => <d>

[45] => <id>3</id>

[46] => <n>objectiveparadox</n>

[47] => <s>qqqqqq</s>
[48] => </d>

[49] => <d>

[50] => <id>4</id>

[51] => <n>macroparadox</n>
[52] => <s>qqqqqq</s>

[53] => </d>

[54] => <d>

[55] => <id>5</id>
[56] => <n>adparadox</n>

[57] => <s>qqqqqq</s>

[58] => </d>

[59] => <d>
[60] => <id>6</id>

[61] => <n>wineparadox</n>

[62] => <s>qqqqqq</s>

[63] => </d>
[64] => <d>

[65] => <id>7</id>

[66] => <n>paradoxwine</n>

[67] => <s>qqqqqq</s>
[68] => </d>

[69] => <d>

[70] => <id>8</id>

[71] => <n>lordparadox</n>
[72] => <s>qqqqqq</s>

[73] => </d>

[74] => <d>

[75] => <id>9</id>
[76] => <n>madparadox</n>

[77] => <s>qqqqqq</s>

[78] => </d>

[79] => <d>
[80] => <id>10</id>

[81] => <n>paradoxfoods</n>

[82] => <s>qqqqqq</s>

[83] => </d>
[84] => <d>

[85] => <id>11</id>

[86] => <n>doctorparadox</n>

[87] => <s>qxqqqq</s>
[88] => </d>

[89] => <d>

[90] => <id>12</id>

[91] => <n>paradoxrealm</n>
[92] => <s>qqqqqq</s>

[93] => </d>

[94] => <d>

[95] => <id>13</id>
[96] => <n>temporalparadox</n>

[97] => <s>qxqqqq</s>

[98] => </d>

[99] => <d>
[100] => <id>14</id>

[101] => <n>paradoxsolution</n>

[102] => <s>qqqqqq</s>

[103] => </d>
[104] => <d>

[105] => <id>15</id>

[106] => <n>radioparadox</n>

[107] => <s>qqqqqq</s>
[108] => </d>

[109] => <d>

[110] => <id>16</id>

[111] => <n>tradeparadox</n>
[112] => <s>qqqqqq</s>

[113] => </d>

[114] => <d>

[115] => <id>17</id>
[116] => <n>paradoxunlimited</n>

[117] => <s>qqqqqq</s>

[118] => </d>

[119] => <d>
[120] => <id>18</id>

[121] => <n>bretsparadox</n>

[122] => <s>qqqqqq</s>

[123] => </d>
[124] => <d>

[125] => <id>19</id>

[126] => <n>djparadox</n>

[127] => <s>qqqqqq</s>
[128] => </d>

[129] => <d>

[130] => <id>20</id>

[131] => <n>paradoxsoft</n>
[132] => <s>qqqqqq</s>

[133] => </d>

[134] => </response>

[135] => </whoisapi>
[136] =>

[137] => 0

[138] =>

)
<?xml version="1.0" encoding="iso-8859-1"?>


my question is now how do i parse that and get the results to display..?

Right now the only elements that i want to use from that is what is within the <response></response> tag.

i have never parsed anything like this before. Suggestions are greatly appreciated..

Double Tap
11-03-2005, 11:16 PM
is there any wat just to remove the parts of the array where there is just spaces?

Burhan
11-04-2005, 11:45 AM
Well, I didn't expect you to stick the entire response into an array -- not really something you see everyday ;)

But since you do have it there, the actual 'response' is from array elements 9 till 135. This is the XML response part. The rest is the headers that the script sends back. What you sent it is in the <request> </request> tags, (element 20 - 26), and the result is in the <response> </response> tags.

What you need to do is parse the array and search for the elements that you want.

There are a lot of array parsing functions available in PHP, but perhaps the easiest for you would be to use XML_Serializer package from PEAR.

Double Tap
11-09-2005, 07:10 PM
i have a string, lets call it $string

$string='qqqqqq'

I want to break that string into 6 different strings like:

$str1='q';
$str2='q';
$str3='q';
$str4='q';
$str5='q';
$str6='q';

how can i do that?

Burhan
11-09-2005, 07:48 PM
Why do you want to do that? You can access individual characters in a string by supplying their offset:


$string = 'hello';
echo $string{0}; //prints h

Double Tap
11-09-2005, 08:05 PM
thanks for all your help man, the $string will constantly be different. i read up on substr and that worked really well also.

i will have this finished tonight Yea!! i used the unserializer by pear, and wow, that worked perfectly. thanks

if you ever want to become a Whois XML api partner and use there name spinner app or the other applications they have e-mail me and i will send you my code it may assist you in that.

Thanks for every thing.