PHP code example of beishanwen / php-openrtb

1. Go to this page and download the library: Download beishanwen/php-openrtb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

beishanwen / php-openrtb example snippets





eate instance of a Bid Response
$bidResponse = new \openrtb\BidResponse();

//Set the Bid Response id
$bidResponse->set('id','ABC123');

//Create instance of a Bid model
$bid = new \openrtb\models\Bid();

//Set the Bid Response attributes
$bid->set('id','ABC123');
$bid->set('impid','ABC123');
$bid->set('price',1.2);

//Create instance of a Seat Bid model
$seatBid = new \openrtb\models\SeatBid();

//Attach the Bid model to the Seat Bid model
$seatBid->set('bid',array(
  $bid
));

//Attach Seat Bid model to the Bid Response
$bidResponse->set('seatbid',$seatBid);

//Output the Bid Reponse as JSON
var_dump($bidResponse->getDataAsJson());
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
composer.phar