Exemple #1
0
}
//Get BidRequestsa
try {
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $jsonData = file_get_contents('php://input');
    } else {
        $jsonData = file_get_contents(__DIR__ . '/example_requests/sticky_ads_example_2.txt');
    }
    $bidRequest = new \openrtb\BidRequest();
    $bidRequest->hydrate($jsonData);
} catch (\Exception $e) {
    var_dump($e->getMessage());
}
addDelay();
//Get impression(s) info
$imp = $bidRequest->get('imp');
$noImp = !isset($imp[0]);
//Constructing BidResponse
$bidResponse = new \openrtb\BidResponse();
$bidResponse->set('id', $bidRequest->get('id'));
//Randomly generate a no bid response for 0.5% of BidRequests
if (rand(1, 200) === 1 || $noImp) {
    $bidResponse->set('seatbid', []);
    $nbr = $noImp ? 2 : rand(0, 8);
    $bidResponse->set('nbr', $nbr);
} else {
    $bidResponse->set('bidid', sha1(uniqid()));
    //Unique BidID for this BidResponse
    //Generate 1 or 2 SeatBid
    $bidders = ['42', '69'];
    $numSeatBid = rand(1, 2);