getError() 공개 메소드

Returns the latest error if there is one.
public getError ( ) : mixed
리턴 mixed The error array, or null if no error
예제 #1
0
include 'globals.php';
$api_url = 'http://localhost/mediawiki/api.php';
echo "Connecting to: {$api_url}\n";
echo "Enter your username: "******"Enter your password: "******"Attempting to log in . . . ";
    if ($wiki->login($username, $password)) {
        echo "Success.\n";
    } else {
        $error = $wiki->getError();
        echo "\nWikimate error: " . $error['login'] . "\n";
        exit(1);
    }
} catch (Exception $e) {
    echo "\nWikimate exception: " . $e->getMessage() . "\n";
    exit(1);
}
echo "Fetching 'Sausages'...\n";
$page = $wiki->getPage('Sausages');
// check if the page exists or not
if (!$page->exists()) {
    echo "'Sausages' doesn't exist.\n";
} else {
    // get the page title
    echo "Title: " . $page->getTitle() . "\n";
function writeOnWiki($output, $CONFIG)
{
    try {
        // Write outpput on wiki page
        $wiki = new Wikimate($CONFIG['WIKI_API_URL']);
        if (!$wiki->login($CONFIG['WIKI_USERNAME'], $CONFIG['WIKI_PASSWORD'])) {
            $error = $wiki->getError();
            return "Wikimate error: " . $error['login'];
        }
    } catch (Exception $e) {
        // Some wiki error
        return "Wikimate error: " . $e->getMessage();
    }
    // Connect to required page
    $page = $wiki->getPage($CONFIG['WIKI_PAGE']);
    if (!$page->exists()) {
        // No page found error
        return "No such page: " . $CONFIG['WIKI_PAGE'];
    }
    try {
        // Try to write on the page
        if (!$page->setText($output)) {
            return "Page was not updated. " . print_r($page->getError());
        }
    } catch (Exception $e) {
        // Some wiki error
        return "Error updating page: " . $e->getMessage();
    }
}