API test for WDS66-API integrated
authorRoland Häder <roland@mxchange.org>
Sun, 10 Feb 2008 17:03:19 +0000 (17:03 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 10 Feb 2008 17:03:19 +0000 (17:03 +0000)
inc/extensions/ext-wernis.php
inc/language/wernis_de.php
inc/libs/wernis_functions.php

index 8c2d64d032a8c822e4dea46a35b481d8afdc5fdb..e8cb4a10aae517b0b6b85e8f3e6176d7a51cfb13 100644 (file)
@@ -114,5 +114,9 @@ $EXT_LANG_PREFIX = "wernis";
 // Extension is always active?
 $EXT_ALWAYS_ACTIVE = 'N';
 
+// Init array
+global $WERNIS;
+$WERNIS = array();
+
 //
 ?>
index a57ab71099538878fba253c0eb2e7b77d2626a3d..5ba4027ee6d371ee3e6f062a04013897dd4cb6a0 100644 (file)
@@ -57,5 +57,9 @@ define('WERNIS_API_REQUEST_ERROR', "Abfragefehler: <u>%s</u>");
 define('WERNIS_API_REQUEST_FAILED', "Unbekannter Fehler <u>%s</u> von API erhalten! Bitte im [<A href=\"http://forum.mxchange.org\" target=\"_blank\" title=\"Direktlink zum Forum\">Forum melden</A>], den Fehlercode nennen und wie es dazu gekommen ist.");
 define('WERNIS_API_REQUEST_FAILED_AUTH', "Authorisierung an API fehlgeschlagen! Bitte API-ID und Key &uuml;berpr&uuml;fen. [<A href=\"http://www.wds66.com/modules.php?module=export\" target=\"_blank\" title=\"Direkt zum WDS66-Exportaccount\">Hier</A>] direkt zum Export-Account. Sie ben&ouml;tigen Ihren Usernamen und Passwort!");
 
+// Error messages
+define('WERNIS_ERROR_STATUS', "Fehler-Status <u>%s</u> erhalten.");
+define('WERNIS_UNKNOWN_ERROR', "Unbekannter Fehler aufgetreten!");
+
 //
 ?>
index 8dff531395a50d113505ea7b95e4acf584e499c0..ea3840079e516a1162d0db17721d7642e1db9c16 100644 (file)
@@ -37,6 +37,28 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        require($INC);
 }
 
+// Sets a status message and code
+function WERNIS_STATUS_MESSAGE ($msg, $status) {
+       global $WERNIS;
+       $WERNIS['message'] = $msg;
+       $WERNIS['status'] = $status;
+}
+
+// Get the status message
+function WERNIS_ERROR_MESSAGE () {
+       global $WERNIS;
+       if (isset($WERNIS['message'])) {
+               // Use raw message
+               return $WERNIS['message'];
+       } elseif (isset($WERNIS['status'])) {
+               // Fall-back to status
+               return sprintf(WERNIS_ERROR_STATUS, $WERNIS['status']);
+       } else {
+               // Something bad happend
+               return WERNIS_UNKNOWN_ERROR;
+       }
+}
+
 // Sends out a request to the API and returns it's result
 function WERNIS_SEND_REQUEST ($scriptName, $requestData =  array()) {
        global $CONFIG;
@@ -126,11 +148,21 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData =  array()) {
 function WERNIS_TEST_API () {
        // Get config first
        global $CONFIG;
+       $result = false;
 
-       // Prepare the request to the API
+       // Return the result from the lower functions
        $return = WERNIS_SEND_REQUEST("balance.php");
 
-       die("<pre>".print_r($return, true)."</pre>");
+       if ($return['status'] == "OK") {
+               // All fine!
+               $result = true;
+       } else {
+               // Status failture text
+               WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
+       }
+
+       // Return result
+       return $result;
 }
 
 //