连接到域注册 EPP 服务器 [英] Connecting to domain registry EPP server

查看:35
本文介绍了连接到域注册 EPP 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了我的海腿,需要一些指针和一个连接到 epp 服务器的小代码示例.代码示例需要登录并发送一个命令并接收一个响应.(以 XML 格式).代码可以是 php 或 python.

I'm getting my sea legs and need some pointers and a small sample of code that connects to an epp server. The sample of code need to login and send one command and receive a response.(in XML). Code can be in php or python.

我相信这将成为我进一步深入研究并了解有关此主题的更多信息的基础/启动.它把我逼到了绝境——这是一种很好的方式,因为我想在一天或一千天内解决它.

This I believe will form a basis/kickstart for me to delve in further and learn more about this topic. It's driving me up the wall - in a good way as I want to solve it in one day or a thousand.

我已经搜索了几天,但似乎无法理解找到的信息,并且现在选择在这里寻求指导.

And I have been searching for days now but can't seem to make sense of the info found, and now opted to ask here for guidance.

提前致谢.

推荐答案

This is sample php script

This is sample php script

<?php


class Epp 
{

var $socket;

public function __construct()
{
}


private $_connected = false;

function connect($host, $port = 700, $timeout = 1, $ssl = true)
{
    if ($this->_connected)
        return true;
    $target = sprintf('%s://%s', ($ssl === true ? 'ssl' : 'tcp'), $host);
    $socket = fsockopen($target, $port, $errno, $errstr, $timeout);
    if (!$socket) {
        return new PEAR_Error("Error connecting to $target: $errstr (code $errno)");
    } else {
        $this->socket = $socket;
        $this->_connected = true;
        return $this->getFrame();
    }
}


function getFrame()
{
    if (feof($this->socket))
        return new PEAR_Error("Connection appears to have closed.");
    $hdr = @fread($this->socket, 4);
    if (empty($hdr)) {
        return new PEAR_Error("Error reading from server: $php_errormsg");
    } else {
        $unpacked = unpack('N', $hdr);
        $answer = fread($this->socket, ($unpacked[1] - 4));
        return $answer;
    }
}

function sendFrame($xml)
{
    return @fwrite($this->socket, pack('N', (strlen($xml) + 4)) . $xml);
}

function disconnect()
{
    return @fclose($this->socket);
}

}

?>

并且有4个函数,connect、getFrame、sendFrame、disconnect.Epp 协议的工作原理如下.首先,您必须连接到服务器.

And there are 4 functions , connect , getFrame , sendFrame , disconnect . Epp protocol works following . Firstly you must connect to server .

向服务器发送 xml 请求并从服务器接收 xml 响应.

Send xml request to server and receive xml response from server .

首先你必须登录到服务器.为此,您必须将登录 xml 发送到服务器.

And firstly you must login to server . for that you must send login xml to server .

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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><?php echo $username;?></clID>
            <pw><?php echo $password;?></pw>
            <options>
                <version>1.0</version>
                <lang>en</lang>
            </options>
            <svcs>
                <svcExtension>

                </svcExtension>
            </svcs>
        </login>
        <clTRID>12345</clTRID>
    </command>
</epp>

所有请求和响应都是 xml .你可以从这个站点找到 xmlshttp://tools.ietf.org/html/rfc5732

All request and responses is xml . And you can find xmls from this sites http://tools.ietf.org/html/rfc5732

这篇关于连接到域注册 EPP 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆