コード例 #1
0
ファイル: test_api.php プロジェクト: egruel/jus-de-corossol
function test_Env_Country($userData)
{
    $result = default_value();
    $start = microtime_float();
    /* Initialisation */
    $env = new Env_Country(array("user" => $userData["login"], "pass" => $userData["password"], "key" => $userData["api_key"]));
    $env->setEnv('test');
    $env->getCountries();
    $env->getCountry("NL");
    /* Reception test */
    if ($env->curlError) {
        $result['reception'] = max($result['reception'], ERROR);
        $result['reception_info'][count($result['reception_info'])] = 'Error while sending the query';
    } else {
        if ($env->respError) {
            $result['reception'] = max($result['reception'], ERROR);
            $result['reception_info'][count($result['reception_info'])] = 'Invalid query : ' . $userData["api_key"];
            foreach ($env->respErrorsList as $message) {
                $result['reception_info'][count($result['reception_info'])] = $message['message'];
            }
        } else {
            $result['reception'] = max($result['reception'], OK);
            $result['reception_info'][count($result['reception_info'])] = 'Reception time : ' . (microtime_float() - $start) . 's';
        }
    }
    /* Additionals test */
    /* Test for the result structure */
    $result['additionals'][0]['name'] = 'Structure';
    $result['additionals'][0]['state'] = OK;
    if (count($env->countries) == 0) {
        $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], WARNING);
        $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '$countries array is empty';
    } else {
        foreach ($env->countries as $x => $country) {
            if (!isset($env->countries[$x]['label'])) {
                $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], ERROR);
                $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '"label" not defined in $countries["' . $x . '"] array';
            }
            if (!isset($env->countries[$x]['code'])) {
                $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], ERROR);
                $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '"code" not defined in $countries["' . $x . '"] array';
            }
        }
    }
    if (count($env->country) == 0) {
        $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], WARNING);
        $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '$country array is empty';
    } else {
        foreach ($env->country as $x => $country) {
            if (!isset($env->country[$x]['label'])) {
                $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], ERROR);
                $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '"label" not defined in $country[' . $x . '] array';
            }
            if (!isset($env->country[$x]['code'])) {
                $result['additionals'][0]['state'] = max($result['additionals'][0]['state'], ERROR);
                $result['additionals'][0]['info'][count($result['additionals'][0]['info'])] = '"code" not defined in $country[' . $x . '] array';
            }
        }
    }
    $result['duration'] = microtime_float() - $start;
    return $result;
}
コード例 #2
0
ファイル: bill.php プロジェクト: sineus/admin.ironova.com
    } else {
        echo "La requête n'est pas valide : ";
        foreach ($cotCl->respErrorsList as $m => $message) {
            echo "<br />" . $message["message"];
        }
    }
} else {
    echo "<b>Une erreur pendant l'envoi de la requête </b> : " . $cotCl->curlErrorText;
    die;
}
?>
<h3>Liste des pays (file: get_country_simple.php)</h3>
<?php 
$countriesStyle = 'style="font-weight:bold;"';
// Initialisation de la classe pays
$countryCl = new Env_Country(array("user" => $userData["login"], "pass" => $userData["password"], "key" => $userData["api_key"]));
// Récupération des pays
$countryCl->getCountries();
?>
<p>
	<label for="countries">Sélectionnez votre pays : </label>
	<select id="countries" name="countries">
<?php 
foreach ($countryCl->countries as $c => $country) {
    ?>
  
			<option value="<?php 
    echo $country['code'];
    ?>
"><?php 
    echo $country['label'];
コード例 #3
0
<?php

include_once 'config.api.php';
//INITIALIZE CLASS CATEGORY
$countryCl = new Env_Country(array("user" => $userData["login"], "pass" => $userData["password"], "key" => $userData["api_key"]));
//RETRIEVE COUNTRY LIST
$countryCl->getCountries();
echo json_encode($countryCl);