metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
214 stars 160 forks source link

create contact #41

Closed pc-partner closed 8 years ago

pc-partner commented 8 years ago

Xml isn't complete. seems to be missing for dns.be

metaregistrar commented 8 years ago

Make sure you are using a dnsbeEppCreateContactRequest, and not the standard eppCreateContactRequest.

The dnsbeEppCreateContactRequest contains the needed extensions

pc-partner commented 8 years ago

Ok changed it in: $contact = new dnsbeEppCreateContactRequest($contactinfo); But then it can’t find it: Fatal error: Class 'dnsbeEppCreateContactRequest' not found in …. Do I need to include the file seperatly?

metaregistrar commented 8 years ago

Please use not the standard eppConnection, but dnsbeEppConnection.

$conn = new dnsbeEppConnection('');

pc-partner commented 8 years ago

Hi again. Tried: require('../autoloader.php');

use Metaregistrar\EPP\eppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppContactPostalInfo; use Metaregistrar\EPP\eppContact; use Metaregistrar\EPP\eppCreateContactRequest; try { if ($conn = dnsbeEppConnection::create('settings.ini',true )) { // Connect to the EPP server if ($conn->login()) { createcontact($conn, 'info@test.com', '+31.201234567', 'Domain Administration', 'Metaregistrar', 'Address 1', 'Zipcode', 'City', 'NL'); $conn->logout(); } } } catch (eppException $e) { echo "ERROR: " . $e->getMessage() . "\n\n"; }

Result: Fatal error: Class 'dnsbeEppConnection' not found in Examples\createcontact.php on line 16

webdevvie commented 8 years ago

Hey @pc-partner it looks like you didn't "use" dnsbeEppConnection before actually using it in your code.

You are required to "use" it or use a complete namespace when calling it. http://php.net/manual/en/language.namespaces.importing.php

try adding this to your list of "use" calls : use Metaregistrar\EPP\dnsbeEppConnection;

metaregistrar commented 8 years ago

You can do either: $conn = new dnsbeEppConnection(...);

or

$conn = eppConnection::create('settings.ini'); But then you must make sure that settings.ini contains: connection=dnsbeEppConnection

pc-partner commented 8 years ago

Hi, use Metaregistrar\EPP\dnsbeEppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppContactPostalInfo; use Metaregistrar\EPP\eppContact; use Metaregistrar\EPP\eppCreateContactRequest; use Metaregistrar\EPP\dnsEppCreateContactRequest;

With: $conn = dnsbeEppConnection::create('settings.ini',true)

And in the function: createcontact: $contact = new dnsbeEppCreateContactRequest($contactinfo);

I still get the error Fatal error: Class 'dnsbeEppCreateContactRequest' not found in.... Although I incude the dnsEppCreateContactRequest class.

metaregistrar commented 8 years ago

Hi Pc Partner,

Please do not use $conn=dnsbeEppConnection::create

But use $conn = new dnsbeEppConnection() instead.

metaregistrar commented 8 years ago

The correct use statement is

use Metaregistrar\EPP\dnsbeEppCreateContactRequest;

You have a typo in use Metaregistrar\EPP\dnsEppCreateContactRequest;

pc-partner commented 8 years ago

Thans, stupid. Again one step further but then: Fatal error: Class 'Metaregistrar\EPP\dnsbeEppCreateContactResponse' not found in xxx

metaregistrar commented 8 years ago

If you have manually included dnsbeEppCreateContactRequest, you should do the same with dnsbeEppCreateContactResponse.

Do not forget to also make the "use" statement.

pc-partner commented 8 years ago

I also included: use Metaregistrar\EPP\dnsbeEppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactResponse;

But same problem: Fatal error: Class 'Metaregistrar\EPP\dnsbeEppCreateContactResponse' not found in xxx\Protocols\EPP\eppConnection.php on line 764

metaregistrar commented 8 years ago

Did you use "new dnsbeEppConnection" or have you included the classes yourself?

In the last case you still need an include statement for dnsbeEppCreateContactResponse.

pc-partner commented 8 years ago

I used the new dns yes... See code:

use Metaregistrar\EPP\dnsbeEppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppContactPostalInfo; use Metaregistrar\EPP\eppContact; use Metaregistrar\EPP\eppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactResponse;

try { // Please enter your own settings file here under before using this example if ($conn = new dnsbeEppConnection(true,'settings.ini')) { // Connect to the EPP server if ($conn->login()) { createcontact($conn, 'info@test.com', '+31.201234567', 'Domain Administration', 'Metaregistrar', 'Address 1', 'Zipcode', 'City', 'NL'); $conn->logout(); } } } catch (eppException $e) { echo "ERROR: " . $e->getMessage() . "\n\n"; }

function createcontact($conn, $email, $telephone, $name, $organization, $address, $postcode, $city, $country) { $postalinfo = new eppContactPostalInfo($name, $city, $country, $organization, $address, null, $postcode); $contactinfo = new eppContact($postalinfo, $email, $telephone); $contactinfo->setPassword(''); $contact = new dnsbeEppCreateContactRequest($contactinfo); if ($response = $conn->request($contact)) { //@var $response Metaregistrar\EPP\eppCreateContactResponse echo "Contact created on " . $response->getContactCreateDate() . " with id " . $response->getContactId() . "\n"; return $response->getContactId(); } else { echo "Create contact failed"; } return null; }

metaregistrar commented 8 years ago

Hi Pc-partner

Let me try this for you and get back to you

metaregistrar commented 8 years ago

With your code i was able to create a contact

Please make sure you have "include('autoloader.php');"

Slight alteration: $postalinfo = new eppContactPostalInfo($name, $city, $country, $organization, $address, null, $postcode,eppContact::TYPE_LOC); $contactinfo->setPassword('dddede');

You MUST set a password with DNS BE

And you must specify TYPE_LOC (local) for the contact.

pc-partner commented 8 years ago

Hi, I include autoloader: require('../autoloader.php'); (I'm in the Examples folder). I also added your code to my project but the same error is occuring:

Fatal error: Class 'Metaregistrar\EPP\dnsbeEppCreateContactResponse' not found in xxx\Protocols\EPP\eppConnection.php on line 764

pc-partner commented 8 years ago

Can you attach your file that is working for you so I can compare?

pc-partner commented 8 years ago

Hi, Do you still want to help me? Or? Thanks for replying.

metaregistrar commented 8 years ago

I had already deleted the test file again, but i will re-create it and send it to you.

metaregistrar commented 8 years ago

My file looks like this now and it works. Please download the latest version of php-epp-connection, because i have made a fix because settings file was not always found correctly.

<?php use Metaregistrar\EPP\dnsbeEppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppContactPostalInfo; use Metaregistrar\EPP\eppContact; use Metaregistrar\EPP\eppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactResponse; include_once('../vendor/autoload.php');

try { // Please enter your own settings file here under before using this example if ($conn = new dnsbeEppConnection(true,'../settings/dnsbe/settings.ini')) { // Connect to the EPP server if ($conn->login()) { createcontact($conn, 'info@test.com', '+31.201234567', 'Domain Administration', 'Metaregistrar', 'Address 1', 'Zipcode', 'City', 'NL'); $conn->logout(); } } } catch (eppException $e) { echo "ERROR: " . $e->getMessage() . "\n\n"; }

function createcontact($conn, $email, $telephone, $name, $organization, $address, $postcode, $city, $country) { $postalinfo = new eppContactPostalInfo($name, $city, $country, $organization, $address, null, $postcode); $contactinfo = new eppContact($postalinfo, $email, $telephone); $contactinfo->setPassword(''); $contact = new dnsbeEppCreateContactRequest($contactinfo); if ($response = $conn->request($contact)) { //@var $response Metaregistrar\EPP\eppCreateContactResponse echo "Contact created on " . $response->getContactCreateDate() . " with id " . $response->getContactId() . "\n"; return $response->getContactId(); } else { echo "Create contact failed"; } return null; }

pc-partner commented 8 years ago

Hi,

I've downloaded the project again and updated my files. Add a settings folder (was not there)\dnsbe\settings.ini I changed include_once('../autoload.php'); to include_once('../autoloader.php'); => In you projects folders it calls autoloader? Or am I downloading the wrong project?? Downloaded this one: https://github.com/metaregistrar/php-epp-client

I ran the code, and got: Fatal error: Class 'Metaregistrar\EPP\dnsbeEppCreateContactResponse' not found in XX\Protocols\EPP\eppConnection.php on line 768

metaregistrar commented 8 years ago

The reason that i call autoload.php is because i am using Composer to load the php-epp-client project

If you just download the project, it is better to call autoloader.php, that is right. I will try my code again using autoloader.php instead of composer.

metaregistrar commented 8 years ago

OK, i have used your method of include('autoloader.php') and i got exactly the same problem as you. I have solved the issue

Please download the latest version of php-epp-client and find the correct version of your script here under:

<?php use Metaregistrar\EPP\dnsbeEppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppContactPostalInfo; use Metaregistrar\EPP\eppContact; use Metaregistrar\EPP\eppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactRequest; use Metaregistrar\EPP\dnsbeEppCreateContactResponse; include_once('../autoloader.php');

try { // Please enter your own settings file here under before using this example if ($conn = new dnsbeEppConnection(true,'../Registries/dnsbeEppConnection/settings.ini')) { // Connect to the EPP server if ($conn->login()) { createcontact($conn, 'info@test.com', '+31.201234567', 'Domain Administration', 'Metaregistrar', 'Address 1', 'Zipcode', 'City', 'NL'); $conn->logout(); } } } catch (eppException $e) { echo "ERROR: " . $e->getMessage() . "\n\n"; }

function createcontact($conn, $email, $telephone, $name, $organization, $address, $postcode, $city, $country) { $postalinfo = new eppContactPostalInfo($name, $city, $country, $organization, $address, null, $postcode,eppContact::TYPE_LOC); $contactinfo = new eppContact($postalinfo, $email, $telephone); $contactinfo->setPassword('test'); $contact = new dnsbeEppCreateContactRequest($contactinfo); if ($response = $conn->request($contact)) { //@var $response Metaregistrar\EPP\eppCreateContactResponse echo "Contact created on " . $response->getContactCreateDate() . " with id " . $response->getContactId() . "\n"; return $response->getContactId(); } else { echo "Create contact failed"; } return null; }

pc-partner commented 8 years ago

That works! perfect !