PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Connecting to an epp server
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Connecting to an epp server

Réponse
 
LinkBack Outils de la discussion
Vieux 09/04/2008, 22h49   #1
Alan Willsher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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);

}
?>

  Réponse avec citation
Vieux 10/04/2008, 15h35   #2
Paul van Brouwershaven
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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);
>
> }
> ?>
>

  Réponse avec citation
Vieux 10/04/2008, 16h32   #3
Alan Willsher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
>
>


  Réponse avec citation
Vieux 11/04/2008, 07h31   #4
Paul van Brouwershaven
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
>>
>>

>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 15h52.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20208 seconds with 12 queries