PHP code example of upmind / 20i-php-sdk

1. Go to this page and download the library: Download upmind/20i-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

upmind / 20i-php-sdk example snippets



$general_api_key = "API KEY";
$services_api = new \TwentyI\API\Services($general_api_key);
$type = "5678";
$domain_name = "example.org";
$other_domain_names = ["example.net"];

$response = $services_api->postWithFields(
    "/reseller/*/addWeb",
    [
      "type" => $type,
      "domain_name" => $domain_name,
      "extra_domain_names" => $other_domain_names,
    ]
);


$general_api_key = "API KEY";
$services_api = new \TwentyI\API\Services($general_api_key);

$domains = $services_api->getWithFields("/domain");
foreach ($domains as $domain) {
    if ($domain->name == "example.org") {
        $id = $domain->id;
        $old_nameservers = $services_api->getWithFields(
            "/domain/{$id}/nameservers"
        )->result;
        $services_api->postWithFields(
            "/domain/{$id}/nameservers",
            [
                "ns" => ["ns1.example.org", "ns2.example.org"],
                "old-ns" => $old_nameservers,
            ]
        );
    }
}


$general_api_key = "API KEY";
$services_api = new \TwentyI\API\Services($general_api_key);
$domains = $services_api->getWithFields("/domain-search/mybusinessname");
print_r($domains);


$oauth_client_key = "CLIENT KEY";
$username = "mycoolusername";
$password = "thatpasswordilike";

$auth_api = new \TwentyI\API\Authentication($oauth_client_key);
$response = $auth_api->postWithFields("/login/authenticate", [
    "grant_type" => "password",
    "username" => $username,
    "password" => $password,
]);
$new_access_token = $response->access_token;


$oauth_client_key = "CLIENT KEY";
$subuser_reference = "stack-user:97";

$auth_api = new \TwentyI\API\Authentication($oauth_client_key);
$response = $auth_api->postWithFields("/login/authenticate", [
    "grant_type" => "client_credentials",
    "scope" => $subuser_reference,
]);
$new_access_token = $response->access_token;

$oauth_client_key = "CLIENT KEY";
$general_api_key = "API KEY";

$services_api = new \TwentyI\API\Services($general_api_key);
$auth_api = new \TwentyI\API\Authentication($oauth_client_key);


$all_packages = $services_api->getWithFields("/package");
$package_id = $all_packages[0]->id; // This is just your first package

$stack_users = $services_api->getWithFields("/package/{$package_id}/stackUserList");
$token_info = $auth_api->controlPanelTokenForUser(
    $stack_users[0]->identity
);
$url = $services_api->singleSignOn($token_info->access_token, $package_info->name);