apikeys()

Request is sent by using login data, and as a result, API keys of a specific user account are returned.

apikeys(string $username, string $password, boolean $expired) : array
Input parametrs
  • username - Mailigen username
  • password - Mailigen password
  • expired - expired API keys (optional): 
    • true - to return all API keys 
    • false (default value) - to return only active API keys
Information obtained

Array of API keys. Each key is represented as an array that includes:

  • apikey - API key
  • created_at - date of key creation
  • expired_at - date of key deactivation

Examples

mgapi_apikeys.php
apikeys($username, $password, $expired);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to get API keys!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "All API Keys for your account:\n";
    foreach ($retval as $key) {
        echo "key = " . $key['apikey'] . "\n";
        echo "\tcreated: = " . $key['created_at'] . "\n";
        echo "\texpired: = " . $key['expired_at'] . "\n";
    }
}
xml-rpc_apikeys.php
 new xmlrpcval($apikey),
                    'username' => new xmlrpcval('admin'),
                    'password' => new xmlrpcval('021rdb089'),
                    'expired' => new xmlrpcval(false)
                ),
                'struct');
$f = new xmlrpcmsg('apikeys', array($v));
$c = new xmlrpc_client($apiUrl["path"], $apiUrl['host'], 80);
$c->setDebug($debug);
$r = &$c->send($f);
 
 
header("Content-Type: text/plain");
if (!$r->faultCode()) {
    $retval = php_xmlrpc_decode($r->value());
    echo "All API Keys for your account:\n";
    foreach ($retval as $key) {
        echo "key = " . $key['apikey'] . "\n";
        echo "\tcreated: = " . $key['created_at'] . "\n";
        echo "\texpired: = " . $key['expired_at'] . "\n";
    }
} else {
    echo "Unable to get API keys!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_apikeys.py

from lib.config import * #contains apikey
from lib.MGAPI import MGAPI
 
# This Example shows how to ping using the MGAPI.php class and do some basic error checking.
 
api = MGAPI(apikey)
 
username = "username"
password = "password"
expired = False
 
retval = api.apikeys(username, password, expired)
if api.errorCode:
    print "Unable to get API keys!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "All API Keys for your account:"
    for key in retval:
        print "key = ", key['apikey']
        print "\tcreated: = ", key['created_at']
        print "\texpired: = ", key['date_expired']

© 2010-2017 Mailigen. All rights reserved.