Connecting to an epp server

This is a discussion on Connecting to an epp server within the PHP General forums, part of the PHP Programming Forums category; Hi im trying to connect to Nominets EPP server Details can be found here http://www.nominet.org.uk/registrars/...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008
Alan Willsher
 
Posts: n/a
Default Connecting to an epp server

Hi im trying to connect to Nominets EPP server

Details can be found here http://www.nominet.org.uk/registrars/systems/epp/

Im trying to send a login request the example can be found here
http://www.nominet.org.uk/registrars/systems/epp/login/

My script seems to connect ok, but im recieving no response when I try to
send the login xml details.


<?
$fp = @fsockopen('ssl://testbed-epp.nominet.org.uk', 700, $errno, $errstr,
100);
echo "(".$errno." ".$errstr.")";
if(!$fp) {
echo "Not Connected!";
}

else {
echo "Connected!\r\n";

$xml = '<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<login>
<clID>EXAMPLE-TAG</clID>
<pw>foo-BAR2</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>http://www.nominet.org.uk/epp/xml/nom-account-1.0
</objURI>
<objURI>http://www.nominet.org.uk/epp/xml/nom-domain-1.0</objURI>
<objURI>http://www.nominet.org.uk/epp/xml/nom-contact-1.0
</objURI>
<objURI>http://www.nominet.org.uk/epp/xml/nom-ns-1.0</objURI>
</svcs>
</login>
<clTRID>ABC-12345</clTRID>
</command>
</epp>';

fputs($fp, $xml, strlen($xml));

while (!feof($fp)) {
$response .= fgets($fp, 128);
}
echo $response;

fclose($fp);

}
?>

Reply With Quote
  #2 (permalink)  
Old 04-10-2008
Paul van Brouwershaven
 
Posts: n/a
Default Re: Connecting to an epp server

don't forget to send the 4 bytes!

Alan Willsher schreef:
> Hi im trying to connect to Nominets EPP server
>
> Details can be found here http://www.nominet.org.uk/registrars/systems/epp/
>
> Im trying to send a login request the example can be found here
> http://www.nominet.org.uk/registrars/systems/epp/login/
>
> My script seems to connect ok, but im recieving no response when I try to
> send the login xml details.
>
>
> <?
> $fp = @fsockopen('ssl://testbed-epp.nominet.org.uk', 700, $errno, $errstr,
> 100);
> echo "(".$errno." ".$errstr.")";
> if(!$fp) {
> echo "Not Connected!";
> }
>
> else {
> echo "Connected!\r\n";
>
> $xml = '<?xml version="1.0" encoding="UTF-8"?>
> <epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
> <command>
> <login>
> <clID>EXAMPLE-TAG</clID>
> <pw>foo-BAR2</pw>
> <options>
> <version>1.0</version>
> <lang>en</lang>
> </options>
> <svcs>
> <objURI>http://www.nominet.org.uk/epp/xml/nom-account-1.0
> </objURI>
> <objURI>http://www.nominet.org.uk/epp/xml/nom-domain-1.0</objURI>
> <objURI>http://www.nominet.org.uk/epp/xml/nom-contact-1.0
> </objURI>
> <objURI>http://www.nominet.org.uk/epp/xml/nom-ns-1.0</objURI>
> </svcs>
> </login>
> <clTRID>ABC-12345</clTRID>
> </command>
> </epp>';
>
> fputs($fp, $xml, strlen($xml));
>
> while (!feof($fp)) {
> $response .= fgets($fp, 128);
> }
> echo $response;
>
> fclose($fp);
>
> }
> ?>
>

Reply With Quote
  #3 (permalink)  
Old 04-10-2008
Alan Willsher
 
Posts: n/a
Default Re: [PHP] Re: Connecting to an epp server

What is 4 bytes ?

On Thu, Apr 10, 2008 at 3:35 PM, Paul van Brouwershaven <
paul@vanbrouwershaven.com> wrote:

> don't forget to send the 4 bytes!
>
> Alan Willsher schreef:
>
> Hi im trying to connect to Nominets EPP server
> >
> > Details can be found here
> > http://www.nominet.org.uk/registrars/systems/epp/
> >
> > Im trying to send a login request the example can be found here
> > http://www.nominet.org.uk/registrars/systems/epp/login/
> >
> > My script seems to connect ok, but im recieving no response when I try
> > to
> > send the login xml details.
> >
> >
> > <?
> > $fp = @fsockopen('ssl://testbed-epp.nominet.org.uk', 700, $errno,
> > $errstr,
> > 100);
> > echo "(".$errno." ".$errstr.")";
> > if(!$fp) {
> > echo "Not Connected!";
> > }
> >
> > else {
> > echo "Connected!\r\n";
> >
> > $xml = '<?xml version="1.0" encoding="UTF-8"?>
> > <epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
> > <command>
> > <login>
> > <clID>EXAMPLE-TAG</clID>
> > <pw>foo-BAR2</pw>
> > <options>
> > <version>1.0</version>
> > <lang>en</lang>
> > </options>
> > <svcs>
> > <objURI>http://www.nominet.org.uk/epp/xml/nom-account-1.0
> > </objURI>
> > <objURI>http://www.nominet.org.uk/epp/xml/nom-domain-1.0
> > </objURI>
> > <objURI>http://www.nominet.org.uk/epp/xml/nom-contact-1.0
> > </objURI>
> > <objURI>http://www.nominet.org.uk/epp/xml/nom-ns-1.0</objURI>
> > </svcs>
> > </login>
> > <clTRID>ABC-12345</clTRID>
> > </command>
> > </epp>';
> >
> > fputs($fp, $xml, strlen($xml));
> >
> > while (!feof($fp)) {
> > $response .= fgets($fp, 128);
> > }
> > echo $response;
> >
> > fclose($fp);
> >
> > }
> > ?>
> >
> >

> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Reply With Quote
  #4 (permalink)  
Old 04-11-2008
Paul van Brouwershaven
 
Posts: n/a
Default Re: [PHP] Re: Connecting to an epp server

epp-example from dns.be:

<?php

//============================================
function mod ($a, $b)
{
return $a % $b;
}
//============================================
class EppSocket {
var $fp = null;

function EppSocket()
{
}

function connect($addr, $port, $timeout)
{
$this->fp = fsockopen ($addr, $port , $errno, $errstr, $timeout);
return 0;
}

function readInteger()
{
$buf = fread($this->fp, 4);
if (strlen($buf) < 4)
{
echo "failed to read 4 bytes \n";
exit;
}
$b0 = ord($buf[0]);
$b1 = ord($buf[1]);
$b2 = ord($buf[2]);
$b3 = ord($buf[3]);
$value = $b3 + 256* ($b2 + 256* ($b1 + 256* $b0));
echo "integer read from socket: $value \n";
return $value;
}

function readString ($bytes)
{
echo "waiting for $bytes bytes\n";
$left = $bytes;
$data = '';
while ( !feof($this->fp) ) {
$chunk = fread($this->fp, $left);
$data .= $chunk;
$left = $left - strlen($chunk);
if ($left == 0)
break;
}
return $data;
}

function readEppString()
{
$len = $this->readInteger();
$len = $len - 4;
return $this->readString ($len);
}

function close()
{
fclose ($this->fp);
}


// this will fail for values bigger than 0x7FFFFFFF (since PHP sucks at math)
// on Windows: PHP thinks that 0xFFFFFFFE modulo 256 = 256 !?!
// on Linux : PHP thinks that 0xFFFFFFFE modulo 256 = -2 !?!

function writeInteger ($value)
{
$b3 = mod ($value, 256);
$value = ($value - $b3)/256;
$b2 = mod ($value, 256);
$value = ($value - $b2)/256;
$b1 = mod ($value, 256);
$value = ($value - $b1)/256;
$b0 = mod ($value, 256);
echo "$value split up in bytes : $b0 $b1 $b2 $b3 \n";
fwrite ($this->fp, chr($b0), 1);
fwrite ($this->fp, chr($b1), 1);
fwrite ($this->fp, chr($b2), 1);
fwrite ($this->fp, chr($b3), 1);
}

function writeEppString ($message)
{
$len = strlen ($message);
echo "len: $len \n";
$len = $len + 4;
echo "total message length: $len bytes \n";
$this->writeInteger ($len);
echo "writing message itself \n";
$written = fwrite ($this->fp, $message);
echo "bytes written: $written \n";
}

}

//================================================== ===
{
$socket = new EppSocket();

$server = "ssl://epp.example.org"; // replace with hostname of your registry's epp server
$port = 33123;
$timeout = 30;

$ok = $socket->connect ($server, $port, $timeout);

if ( $ok != 0)
{
echo "failed to connect to $server, check server name !!";
exit;
}
echo "ok, connected to $server at port $port\n";

$greeting = $socket->readEppString();
echo "=====================\n";
echo "$greeting ";
echo "=====================\n";

$hello = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><epp
xmlns=\"urn:ietf:params:xml:ns:epp-1.0\"> <hello/></epp>";
$socket->writeEppString ($hello);
echo "waiting for reply \n";

$response = $socket->readEppString();
echo "=====================\n";
echo "$response ";
echo "=====================\n";

$garbage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><epp
xmlns=\"urn:ietf:params:xml:ns:epp-1.0\"> <garbage/></epp>";
$socket->writeEppString ($garbage);
$response = $socket->readEppString();
echo "=====================\n";
echo "$response ";
echo "=====================\n";

$socket->close();
}
?>



Alan Willsher schreef:
> What is 4 bytes ?
>
> On Thu, Apr 10, 2008 at 3:35 PM, Paul van Brouwershaven <
> paul@vanbrouwershaven.com> wrote:
>
>> don't forget to send the 4 bytes!
>>
>> Alan Willsher schreef:
>>
>> Hi im trying to connect to Nominets EPP server
>>> Details can be found here
>>> http://www.nominet.org.uk/registrars/systems/epp/
>>>
>>> Im trying to send a login request the example can be found here
>>> http://www.nominet.org.uk/registrars/systems/epp/login/
>>>
>>> My script seems to connect ok, but im recieving no response when I try
>>> to
>>> send the login xml details.
>>>
>>>
>>> <?
>>> $fp = @fsockopen('ssl://testbed-epp.nominet.org.uk', 700, $errno,
>>> $errstr,
>>> 100);
>>> echo "(".$errno." ".$errstr.")";
>>> if(!$fp) {
>>> echo "Not Connected!";
>>> }
>>>
>>> else {
>>> echo "Connected!\r\n";
>>>
>>> $xml = '<?xml version="1.0" encoding="UTF-8"?>
>>> <epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
>>> <command>
>>> <login>
>>> <clID>EXAMPLE-TAG</clID>
>>> <pw>foo-BAR2</pw>
>>> <options>
>>> <version>1.0</version>
>>> <lang>en</lang>
>>> </options>
>>> <svcs>
>>> <objURI>http://www.nominet.org.uk/epp/xml/nom-account-1.0
>>> </objURI>
>>> <objURI>http://www.nominet.org.uk/epp/xml/nom-domain-1.0
>>> </objURI>
>>> <objURI>http://www.nominet.org.uk/epp/xml/nom-contact-1.0
>>> </objURI>
>>> <objURI>http://www.nominet.org.uk/epp/xml/nom-ns-1.0</objURI>
>>> </svcs>
>>> </login>
>>> <clTRID>ABC-12345</clTRID>
>>> </command>
>>> </epp>';
>>>
>>> fputs($fp, $xml, strlen($xml));
>>>
>>> while (!feof($fp)) {
>>> $response .= fgets($fp, 128);
>>> }
>>> echo $response;
>>>
>>> fclose($fp);
>>>
>>> }
>>> ?>
>>>
>>>

>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0