login()

By using login data of a user, you can find an API key, but if there is no API key, it will be created.

login(string $username, string $password) : string
Input parametrs
  • username
  • password
Information obtained
  • API key (if there is no API key, it will be created)

Examples

mgapi_login.php
login($username, $password);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to get API key!\n";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Returned API key: " . $retval . "\n";
} 
xml-rpc_login.php
 new xmlrpcval('username'),
                    'password' => new xmlrpcval('password')
                ),
                'struct');
$f = new xmlrpcmsg('login', 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 "Returned API key: " . $retval . "\n";
} else {
    echo "Unable to get API key!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_login.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"
 
retval = api.login(username, password)
if api.errorCode:
    print "Unable to get API key!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Returned API key: ", retval

© 2010-2017 Mailigen. All rights reserved.