简体   繁体   English

如何发送 XML (epp) 请求然后接收数据? (PHP)

[英]How can I send XML (epp) request and then receive data? (PHP)

I've been in the process of searching for the code all day, and now I've decided to write it here.我整天都在寻找代码的过程中,现在我决定把它写在这里。

First Login:首次登录:

<epp xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<login>
<clID>ClientX</clID>
<pw>epp123</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
<svcExtension>
<extURI>http://test/epp/xml/schema/contact-ext-1.0</extURI>
</svcExtension>
</svcs>
</login>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

Then: Some XML然后:一些XML

And then Logout:然后注销:

<epp xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<logout />
<clTRID>ABC-12345</clTRID>
</command>
</epp>

How can I send this data and then receive data from the server?如何发送这些数据,然后从服务器接收数据? Can anyone send me example?谁能给我发个例子?

Thank you谢谢

How can I send this data and then receive data from the server?如何发送这些数据,然后从服务器接收数据?

Read RFC 5734 "Extensible Provisioning Protocol (EPP) Transport over TCP" multiple times, and very carefully.仔细阅读RFC 5734“基于 TCP 的可扩展供应协议 (EPP) 传输”

Of course to really understand it you will need to read all RFCs regarding EPP, that is RFC 5730 to 5733 and then if you are serious about being a registrar you will need to read the one on RGP and the one on secDNS-1.1 for the 2 major extensions used almost everywhere.当然,要真正理解它,您需要阅读所有关于 EPP 的 RFC,即 RFC 5730 到 5733,然后如果您认真考虑成为注册商,您将需要阅读 RGP 上的和 secDNS-1.1 上的2 个主要扩展几乎无处不在。 Then of course registry specific extensions (I believe you are trying to connect to EURid or DNSBelgium).然后当然是注册特定的扩展(我相信你正在尝试连接到 EURid 或 DNSBelgium)。

In short:简而言之:

  • open a TLS socket to the registry EPP server, typically on port 700打开一个到注册表 EPP 服务器的 TLS 套接字,通常在端口 700 上
  • do your cryptography correctly: validate the server certificate!正确执行您的加密:验证服务器证书!
  • start to read, as the server speaks first, with the <greeting>当服务器首先说话时,开始阅读,使用<greeting>
  • extract objURI and extURI from there to build your <login> correctly (check registry documentation for which extensions are mandatory)从那里提取objURIextURI以正确构建您的<login> (检查哪些扩展是强制性的注册表文档)
  • send your <login> frame发送你的<login>框架
  • check the return code, and then do all other command/responses.检查返回码,然后执行所有其他命令/响应。

Make sure to understand from RFC 5734 that each EPP frame has to be prefixed by 4 octets encoding the length of the frame: on input (from registry) this let you know how much data you are getting, on output you have to generate it properly, otherwise the registry won't read your response.确保从 RFC 5734 了解每个 EPP 帧必须以 4 个八位字节为前缀,编码帧的长度:在输入(来自注册表)上,这让您知道您正在获取多少数据,在 output 上,您必须正确生成它,否则注册表将不会读取您的响应。

If you are beginning in the registrar world, building from scratch a proper EPP client may not be the most desirable job, and I wouldn't necessarily recommend you to do that.如果您刚开始在注册商领域,从头开始构建合适的 EPP 客户端可能不是最理想的工作,我不一定建议您这样做。 There are a lot of small details to get right, specifically if you plan to connect to different registries.有很多小细节需要正确处理,特别是如果您计划连接到不同的注册表。

If you search on EPP tag here you can easily find other questions, and answers that should help you:如果您在此处搜索EPP标签,您可以轻松找到其他问题和对您有帮助的答案:

You can also find that PHP libraries exist to do EPP so this might save you some time (and make you loose some in understanding the library and fitting it in your own ecosystem).您还可以找到 PHP 库来执行 EPP,因此这可能会为您节省一些时间(并使您在理解该库并将其安装到您自己的生态系统中放松一些)。 See centralnic PHP EPP library - login frame for a lead for example.请参阅centralnic PHP EPP 库 - 登录框架以获取示例。

PS: I participated in EPP specifications, and wrote multiple EPP clients and servers over the last 20 years or so. PS:我参与了 EPP 规范,并在过去 20 年左右的时间里编写了多个 EPP 客户端和服务器。

First, you need to check how the server API is expecting to receive this data.首先,您需要检查服务器 API 期望如何接收此数据。 So far we know it's expecting XML but how is the XML to be delivered?到目前为止,我们知道它期待 XML 但是 XML 是如何交付的? Questions you should ask:你应该问的问题:

  • What is the type of the API I'm trying to interact with?我尝试与之交互的 API 的类型是什么?
  • Is it a XML-RPC?它是 XML-RPC 吗? SOAP? SOAP? Maybe REST API?也许 REST API?
  • Is it a custom API?是定制的 API 吗?
  • What are the API endpoints?什么是 API 端点?
  • Does this API have a manual?这个API有说明书吗?

The underlying transport mechanism of most web APIs is through HTTP requests.大多数 web API 的底层传输机制是通过 HTTP 请求。 For that you could use PHP native libraries like cURL or PHP libraries like Guzzle .为此,您可以使用 PHP 原生库,如cURL或 PHP 库,如Guzzle Guzzle is a good one if you are dealing with a REST API.如果您正在处理 REST API,Guzzle 是一个不错的选择。

But you can also find more specific libraries like the SOAP client if you are dealing with a SOAP API但是,如果您正在处理 SOAP API,您还可以找到更具体的库,例如SOAP 客户端

UPDATE :更新

I just realized EPP is the protocol.我刚刚意识到 EPP 是协议。 Let me know if this link helps, it uses cURL:如果此链接有帮助,请告诉我,它使用 cURL:

https://doc.openprovider.eu/Example_Script_EPP_PHP https://doc.openprovider.eu/Example_Script_EPP_PHP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM