Exemplo n.º 1
0
// chargement de la config
if (file_exists($CHEMIN_CONFIG)) {
    $config = json_decode(file_get_contents($CHEMIN_CONFIG), true);
} else {
    throw new Exception("Le fichier " . $CHEMIN_CONFIG . " n'existe pas");
}
$baseURI = $config['domain_root'] . $config['base_uri'];
$URIs = $config['test']['uris'];
$success = 0;
$failures = 0;
foreach ($URIs as $URI) {
    $URI = $baseURI . $URI;
    file_get_contents($URI);
    $responseCodeHeader = $http_response_header[0];
    $responseCode = extractCode($responseCodeHeader);
    $status = checkResponse($responseCode);
    if ($status === true) {
        echo "OK {$URI}\n";
        $success++;
    }
    if ($status === false) {
        echo "KO {$URI}\n";
        $failures++;
    }
}
echo count($URIs) . " URIs tested\n";
echo $success . " succeeded\n";
echo $failures . " failed\n";
// lib
function extractCode($header)
{
Exemplo n.º 2
0
/**
 * function that creates individual ads and adds it to the
 * adgroup.
 */
function addAds($adService, $adGroupID)
{
    global $SAMPLE_DATA;
    $ad1 = createAd(NULL, $adGroupID, $SAMPLE_DATA['AD1_DESC'], $SAMPLE_DATA['AD1_DISPLAY_URL'], $SAMPLE_DATA['AD1_NAME'], $SAMPLE_DATA['AD1_SHORT_DESC'], 'On', $SAMPLE_DATA['AD1_TITLE'], $SAMPLE_DATA['AD1_URL']);
    $ad2 = createAd(NULL, $adGroupID, $SAMPLE_DATA['AD2_DESC'], $SAMPLE_DATA['AD2_DISPLAY_URL'], $SAMPLE_DATA['AD2_NAME'], $SAMPLE_DATA['AD2_SHORT_DESC'], 'On', $SAMPLE_DATA['AD2_TITLE'], $SAMPLE_DATA['AD2_URL']);
    debug("Calling addAds");
    //PHP NOTE: In case of nested arrays, only the outer-most
    //element needs to be keyed with the correct param name.
    $adsParam = array('ads' => array($ad1, $ad2));
    $retObj = execute($adService, 'addAds', $adsParam);
    //IMPL NOTE: PHP will treat single element as an object and not an array
    //PHP NOTE: Return values of arrays are structured differently than
    //as described in wsdl.
    if (isset($retObj->out->AdResponse[0]->ad)) {
        checkResponse($retObj->out->AdResponse[0]);
        debug("------> Ad ID: " . $retObj->out->AdResponse[0]->ad->ID);
        checkForEditorialReason($adService, $retObj->out->AdResponse[0]->ad);
    }
    if (isset($retObj->out->AdResponse[1]->ad)) {
        checkResponse($retObj->out->AdResponse[1]);
        debug("------> Ad ID: " . $retObj->out->AdResponse[1]->ad->ID);
        checkForEditorialReason($adService, $retObj->out->AdResponse[1]->ad);
    }
    return $retObj->out;
}