AfterMarket
[ class tree: AfterMarket ] [ index: AfterMarket ] [ all elements ]
Prev Next

API Code Samples

This document contains code samples that use the AfterMarket.pl API.

Code samples

All code samples in this document are provided in PHP5 language. This does not mean that this is the only language which can be used to call the API functions, it is merely an example. If you intend to use other programming language, you can still review these examples to get an idea of how specific operations are performed in the API.

API authentication

This code will use the API to open the authentication session, and perform a simple operation.

try
{
    $AFT = new SoapClient("https://am-soap.com:4192/service.php?class=AfterMarket&wsdl", 
        array("exceptions" => "true", "cache_wsdl" => WSDL_CACHE_MEMORY));
    $email = "someuser@email.com";
    $password = "somepassword";
    $key = $AFT->login($email, $password);
    $balance = $AFT->getBalance($email, $key);
    echo "<p>Account balance is: " . $balance . "<p>\n";
    $AFT->logout($email, $key);
}
catch(Exception $e)
{
    echo "<p>An error occured: " . $e->getMessage() . "</p>\n";
}
        


Listing multiple auctions

This code will read a text file with domain names, and list an auction with each domain (authentication calls omitted for brevity).

$category = "8.";
$days = 7;
$endhour = 20;
$price = 100;
$currency = "EUR";
         
$f = fopen("domains.txt", "r");
$name = chop(fgets($f));
while(!feof($f))
{
    try
    {
        $id = $AFT->addAuction($email, 
            $key, 
            false, 
            $name, 
            $category,
            "",
            $price,
            $currency,
            $name,
            1,
            0,
            "",
            $days,
            $hour,
            false,
            "en",
            0,
            0);
        echo "<b>" . $name . "</b>: Auction ID = <b>" . $id . "</b><br/>\n;
    }
    catch(Exception $e)
    {
        echo "<b>" . $name . "</b>: " . $e->getMessage() . "<br/>\n;
    }
    $name = chop(fgets($f));
}
        


List sorting

This code will retrieve a list of received purchase domain offers sorted by their price. This example illustrates the list sorting mechanism.

$sort = "price+";
// "price-" for sort descending,
// "price+,name+" for combined sort criteria, etc.

try
{
    $list = $AFT->receivedOffers($email, key, 0, 100, $sort);
    if(count($list))
        echo "<p>The lowest received offer is " . $list[0]->price . " " . $list[0]->currency 
            . ", for domain " . $list[0]->name . ".</p>";
}
catch(Exception $e)
{
    echo "<p>An error occured: " . $e->getMessage() . "</p>\n";
}
        


Prev   Next
API Events API Quick Start Guide

Documentation generated on Thu, 18 Aug 2011 10:03:41 +0200 by phpDocumentor 1.4.3