PHPackages                             juangirini/osrs-toolkit-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. juangirini/osrs-toolkit-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

juangirini/osrs-toolkit-php
===========================

OpenSRS PHP Toolkit

024PHP

Since Jan 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/juangirini/osrs-toolkit-php)[ Packagist](https://packagist.org/packages/juangirini/osrs-toolkit-php)[ RSS](/packages/juangirini-osrs-toolkit-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Official OpenSRS PHP Toolkit
============================

[](#official-opensrs-php-toolkit)

The purpose in building out these libraries is to help ease the implementation of the OpenSRS API. Not only does it give a starting point in developing an application to allow for quick integration, but also incorporates new communication markup languages such as JSON and YAML.

Getting Started
---------------

[](#getting-started)

1. Download and install the toolkit
2. In opensrs directory, rename/copy the openSRS\_config.php.template to openSRS\_config.php
3. Open openSRS\_config.php in a text editor and fill in your reseller details [Here](#setup_config)
4. Follow the guidelines to start developing your application.

- [OpenSRS API Documentation Page](http://www.opensrs.com/site/resources/documentation/api)

That's it!

Set up openSRS\_config.php
-------------------------------------------------------------------

[](#set-up-opensrs_configphp-)

**OSRS\_HOST**

> - LIVE: rr-n1-tor.opensrs.net
> - TEST: horizon.opensrs.net

**CRYPT\_TYPE**

> OpenSRS default encryption type
>
> - ssl (default)
> - sslv3
> - tls
>
> Please note that OpenSSL ver 1.0.1e does not work with "ssl" cryption type

**OSRS\_USERNAME**

> OpenSRS Reseller Username

**OSRS\_KEY**

> OpenSRS Private Key To generate a key, login into the RWI by going to the following address,
>
> - LIVE:
> - TEST:
>
> In RWI, Profile Management &gt; Generate New Private Key

**OSRS\_DEBUG**

> WHen set to 1, the Toolkit will spit out the raw XML request/response.

**MAIL\_HOST**

> - LIVE:
> - TEST:

**MAIL\_USERNAME**

> Company level email admin username

**MAIL\_PASSWORD**

> Company level email admin password

**MAIL\_ENV**

> Mail environment - LIVE or TEST

Sample API Call
---------------

[](#sample-api-call)

- Lookup Domain

```
require_once ("your_root_path/opensrs/openSRS_loader.php");

$callArray = array (
        "func" => "lookupLookupDomain",
        "data" => array (
                "domain" => "sometest.com",
        )
);

$osrsHandler = processOpenSRS ("array", $callArray);

var_dump($osrsHandler);
```

Requirements
------------

[](#requirements)

This PHP library currently supports data being passed in JSON and YAML (it is also being extended to pass data in XML and Array format as well).

The OpenSRS PHP Tookit requires:

- PHP 5
- OpenSSL
- PEAR:
- getmypid() enabled
- cURL: required for OMA
- php-curl: required for OMA -

NOTE: It's best to use the PHP 5.3+ as json\_encode and json\_decode are standard on that version and above. If an earlier version of PHP 5 is needed, the php-json libraries at  will be required.

Generating Private Key
----------------------

[](#generating-private-key)

To generate a key, login into the RWI by going to the following address:

```
LIVE:  https://rr-n1-tor.opensrs.net/resellers/
TEST:  https://horizon.opensrs.net/resellers/

```

NOTE: The TEST system is rather different than the LIVE system. Therefore, during testing, the results that you receive are VERY different than you would get on the LIVE system. Both Personal Names and Domain searching will yield different results.

Once authenticated, scroll down to the bottom of the page where the heading shows "Profile Management". Here, there is a link called "Generate New Private Key". If you are sure you wish to continue, click on the 'OK' button on the warning window. This window ensure that you wish to generate a new key. On refresh, you will see a key similiar to this structure:

a2e308f4df69c969de9ada09c39bb43d0e4d0a88ce83fd2c0a193328d16e8bf5080ee7e0ef388fd8aa0dfb42d33dcd02d3de321c9af1f06b

This is essentially the authentication key that you'll be using to working with the API. It's essential to keep this key to yourself!

Whitelisting IP address
-----------------------

[](#whitelisting-ip-address)

Once you've generated your key (as above), you'll also need to whitelist your IP address. If this is not done, an error will be received and continuing with the API will not possible. To whitelist your IP address, login to either LIVE or TEST environment in the RWI (like in section 2.1.0). Scroll down to the bottom of the screen under the "Profile Management" section, there is a link called "Add IPs for Script/API Access". Once you've clicked on that, you can "Add New Rule" by typing in the subnet for where your application will be hosted. A total of 5 addresses can be added by default.

IMPORTANT NOTE: Adding a new IP address can take up to 15 minutes to propagate into our system.

Account Provisioning Protocol (APP) Services
--------------------------------------------

[](#account-provisioning-protocol-app-services)

This APP libs will eventually be deprecated and be replaced by OMA.

NOTE: The APP\_MAIL\_USERNAME, APP\_MAIL\_PASSWORD and APP\_MAIL\_DOMAIN are all elements of a mailbox that has company level access.

The mailbox would be broken down as:

Mailbox address: APP\_MAIL\_USERNAME@APP\_MAIL\_DOMAIN Mailbox password: APP\_MAIL\_PASSWORD

```
define('APP_MAIL_HOST', 'ssl://admin.hostedemail.com'); /*  LIVE => ssl://admin.test.hostedemail.com, TEST => ssl://admin.hostedemail.com */
define('APP_MAIL_USERNAME', '');
define('APP_MAIL_DOMAIN', '');
```

Additional Configuration for customized implementations
-------------------------------------------------------

[](#additional-configuration-for-customized-implementations)

If there are plans to change the include folder name, additional changes need to made to the file:

opensrs/openSRS\_config.php

Changes to the OPENSRSURI constant will need to be made as appropriate. Using the full path name may be necessary on some servers.

```
define ("OPENSRSURI", "/path/to/opensrs/");
```

Further changes can be made to function folders:

```
// Application core configurations.

define("OPENSRSCONFINGS", OPENSRSURI . DS . "configurations");
define("OPENSRSDOMAINS", OPENSRSURI . DS . "domains");
define("OPENSRSTRUST", OPENSRSURI . DS . "trust");
define("OPENSRSPUBLISHING", OPENSRSURI . DS . "publishing");
define("OPENSRSOMA", OPENSRSURI . DS . "OMA");
define("OPENSRSFASTLOOKUP", OPENSRSURI . DS . "fastlookup");
define("OPENSRSMAIL", OPENSRSURI . DS . "mail");
```

NOTE: It's recommended to keep these folder names constant as upgrades to the library may cause files to be put into the wrong folder thus possibily affecting future enhancements.

General Use
-----------

[](#general-use)

In the openSRS\_loader there is a processOpenSRS function which will take in the JSON data and run the appropriate function.

```
	$returnedResult = processOpenSRS($data_type, $call_string)
```

The returnedResult variable will be an object that has the result in a string using the specified data type (json or yaml) and in an array. There is more information about what is returned from these functions later in this documentation. The call string is the JSON or YAML data that is being passed to the library. All examples will be using JSON call strings from here on out.

The call string is broken into two parts:

func:

- This is where the system will look for what function it to be executed from the library

data

- This is the information that is being passed to the function
- Most times this is formatted in a similar way to the XML, which is found in the API documentation.

An example of a call string for looking up the domain "example.com" would be:

Sample JSON request:

```
{
	"func": "lookupDomain",
	"data": {
			"domain": "example.com",
			"alldomains": ".com,.net,.org",
			"selected": ".com,.net"
			}
}
```

Any application will probably use json\_encode($array) and json\_decode($json) instead of constructing the raw json calls itself, but this is a good way to see it broken down to the essentials.

Here is an example of the call string being used:

Sample code:

```
