/**
  * (non-PHPdoc)
  * @see BaseExample::run()
  */
 public function run()
 {
     $values = $this->formValues;
     printf('<h2>Creating HTML5 banner banner creative from HTML5 asset "%s"</h2>', $values['html_asset_file']['name']);
     $creative = new Google_Service_Dfareporting_Creative();
     $creative->setAdvertiserId($values['advertiser_id']);
     $creative->setAutoAdvanceImages(true);
     $creative->setName('Test HTML5 banner creative');
     $creative->setType('HTML5_BANNER');
     $size = new Google_Service_Dfareporting_Size();
     $size->setId($values['size_id']);
     $creative->setSize($size);
     // Upload the flash asset.
     $html_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['html_asset_file'], 'HTML');
     $html_asset = new Google_Service_Dfareporting_CreativeAsset();
     $html_asset->setAssetIdentifier($html_asset_id);
     $html_asset->setRole('PRIMARY');
     // Upload the backup image asset.
     $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE');
     $image_asset = new Google_Service_Dfareporting_CreativeAsset();
     $image_asset->setAssetIdentifier($image_asset_id);
     $image_asset->setRole('BACKUP_IMAGE');
     // Add the creative assets.
     $creative->setCreativeAssets(array($html_asset, $image_asset));
     // Add a click tag.
     $click_tag = new Google_Service_Dfareporting_ClickTag();
     $click_tag->setName('clickTag');
     $creative->setClickTags(array($click_tag));
     $result = $this->service->creatives->insert($values['user_profile_id'], $creative);
     $this->printResultsTable('HTML5 banner creative created.', array($result));
 }
 /**
  * (non-PHPdoc)
  * @see BaseExample::run()
  */
 public function run()
 {
     $values = $this->formValues;
     printf('<h2>Creating flash in-page banner creative from flash asset "%s"</h2>', $values['flash_asset_file']['name']);
     $creative = new Google_Service_Dfareporting_Creative();
     $creative->setAdvertiserId($values['advertiser_id']);
     $creative->setAutoAdvanceImages(true);
     $creative->setName('Test flash in-page creative');
     $creative->setType('FLASH_INPAGE');
     $size = new Google_Service_Dfareporting_Size();
     $size->setId($values['size_id']);
     $creative->setSize($size);
     // Upload the flash asset.
     $flash_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['flash_asset_file'], 'FLASH');
     $flash_asset = new Google_Service_Dfareporting_CreativeAsset();
     $flash_asset->setAssetIdentifier($flash_asset_id);
     $flash_asset->setRole('PRIMARY');
     $flash_asset->setWindowMode('TRANSPARENT');
     // Upload the backup image asset.
     $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE');
     $image_asset = new Google_Service_Dfareporting_CreativeAsset();
     $image_asset->setAssetIdentifier($image_asset_id);
     $image_asset->setRole('BACKUP_IMAGE');
     // Add the creative assets.
     $creative->setCreativeAssets(array($flash_asset, $image_asset));
     // Set up the backup image target window option.
     $target_window = new Google_Service_Dfareporting_TargetWindow();
     $target_window->setTargetWindowOption('NEW_WINDOW');
     $creative->setBackupImageTargetWindow($target_window);
     $result = $this->service->creatives->insert($values['user_profile_id'], $creative);
     $this->printResultsTable('Flash in-page creative created.', array($result));
 }
Exemple #3
0
function uploadAsset($rs)
{
    // globalize vars
    global $stored_rs, $asset_id, $asset_xml;
    // set up upload_xml request
    $upload_xml = curl_init("http://www.roblox.com/Data/Upload.ashx?assetid={$asset_id}");
    curl_setopt_array($upload_xml, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array('User-Agent: Roblox/WinINet', "Cookie: {$rs}"), CURLOPT_POSTFIELDS => $asset_xml));
    // get header & body of request
    $response = curl_exec($upload_xml);
    $header_size = curl_getinfo($upload_xml, CURLINFO_HEADER_SIZE);
    $header = substr($response, 0, $header_size);
    $body = substr($response, $header_size);
    // check if roblosecurity is valid
    if (!preg_match('/HTTP\\/1.1 200/', $header)) {
        if (preg_match('/HTTP\\/1.1 302/', $header) && $rs == $stored_rs) {
            // get updated roblosecurity
            $body = uploadAsset(getRS());
        } else {
            // error
            $body = "error: invalid xml/invalid id";
        }
    }
    // close upload_xml
    curl_close($upload_xml);
    // return results
    return $body;
}
 /**
  * (non-PHPdoc)
  * @see BaseExample::run()
  */
 public function run()
 {
     $values = $this->formValues;
     printf('<h2>Creating image creative from image asset "%s"</h2>', $values['asset_file']['name']);
     $creative = new Google_Service_Dfareporting_Creative();
     $creative->setAdvertiserId($values['advertiser_id']);
     $creative->setName('Test image creative');
     $creative->setType('IMAGE');
     $size = new Google_Service_Dfareporting_Size();
     $size->setId($values['size_id']);
     $creative->setSize($size);
     // Upload the image asset.
     $asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['asset_file'], 'IMAGE');
     $asset = new Google_Service_Dfareporting_CreativeAsset();
     $asset->setAssetIdentifier($asset_id);
     $asset->setRole('PRIMARY');
     // Add the creative asset.
     $creative->setCreativeAssets(array($asset));
     $result = $this->service->creatives->insert($values['user_profile_id'], $creative);
     $this->printResultsTable('Image creative created.', array($result));
 }
 /**
  * (non-PHPdoc)
  * @see BaseExample::run()
  */
 public function run()
 {
     $values = $this->formValues;
     printf('<h2>Creating enhanced banner creative from HTML5 asset "%s"</h2>', $values['html_asset_file']['name']);
     $creative = new Google_Service_Dfareporting_Creative();
     $creative->setAdvertiserId($values['advertiser_id']);
     $creative->setName('Test enhanced banner creative');
     $creative->setType('ENHANCED_BANNER');
     $size = new Google_Service_Dfareporting_Size();
     $size->setId($values['size_id']);
     $creative->setSize($size);
     // Upload the HTML5 asset.
     $html_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['html_asset_file'], 'HTML');
     $html_asset = new Google_Service_Dfareporting_CreativeAsset();
     $html_asset->setAssetIdentifier($html_asset_id);
     $html_asset->setRole('PRIMARY');
     $html_asset->setWindowMode('TRANSPARENT');
     // Upload the backup image asset.
     $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE');
     $image_asset = new Google_Service_Dfareporting_CreativeAsset();
     $image_asset->setAssetIdentifier($image_asset_id);
     $image_asset->setRole('BACKUP_IMAGE');
     // Add the creative assets.
     $creative->setCreativeAssets(array($html_asset, $image_asset));
     // Configure the backup image.
     $creative->setBackupImageClickThroughUrl('https://www.google.com');
     $creative->setBackupImageReportingLabel('backup');
     $target_window = new Google_Service_Dfareporting_TargetWindow();
     $target_window->setTargetWindowOption('NEW_WINDOW');
     $creative->setBackupImageTargetWindow($target_window);
     // Add a click tag.
     $click_tag = new Google_Service_Dfareporting_ClickTag();
     $click_tag->setName('clickTag');
     $click_tag->setEventName('exit');
     $click_tag->setValue('https://www.google.com');
     $creative->setClickTags(array($click_tag));
     $result = $this->service->creatives->insert($values['user_profile_id'], $creative);
     $this->printResultsTable('Enhanced banner creative created.', array($result));
 }
 /**
  * (non-PHPdoc)
  * @see BaseExample::run()
  */
 public function run()
 {
     $values = $this->formValues;
     printf('<h2>Creating enhanced banner creative from images "%s" and "%s"</h2>', $values['image1_asset_file']['name'], $values['image2_asset_file']['name']);
     $creative = new Google_Service_Dfareporting_Creative();
     $creative->setAdvertiserId($values['advertiser_id']);
     $creative->setAutoAdvanceImages(true);
     $creative->setName('Test enhanced image creative');
     $creative->setType('ENHANCED_IMAGE');
     $size = new Google_Service_Dfareporting_Size();
     $size->setId($values['size_id']);
     $creative->setSize($size);
     // Upload the first image asset.
     $image1_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image1_asset_file'], 'HTML_IMAGE');
     $image1_asset = new Google_Service_Dfareporting_CreativeAsset();
     $image1_asset->setAssetIdentifier($image1_asset_id);
     $image1_asset->setRole('PRIMARY');
     // Upload the second image asset.
     $image2_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image2_asset_file'], 'HTML_IMAGE');
     $image2_asset = new Google_Service_Dfareporting_CreativeAsset();
     $image2_asset->setAssetIdentifier($image2_asset_id);
     $image2_asset->setRole('PRIMARY');
     // Add the creative assets.
     $creative->setCreativeAssets(array($image1_asset, $image2_asset));
     // Add a click tag for the first image asset.
     $click_tag1 = new Google_Service_Dfareporting_ClickTag();
     $click_tag1->setName($image1_asset_id->getName());
     $click_tag1->setEventName($image1_asset_id->getName());
     // Add a click tag for the second image asset.
     $click_tag2 = new Google_Service_Dfareporting_ClickTag();
     $click_tag2->setName($image2_asset_id->getName());
     $click_tag2->setEventName($image2_asset_id->getName());
     $creative->setClickTags(array($click_tag1, $click_tag2));
     $result = $this->service->creatives->insert($values['user_profile_id'], $creative);
     $this->printResultsTable('Enhanced image creative created.', array($result));
 }
        return $response;
    } catch (Exception $e) {
        http500($e->getMessage());
    }
}
// End of functions, begin our script here.
// We can't use $_POST since that only works if we are posting urlencoded data
// and not pure JSON.
$requestObject = json_decode(file_get_contents("php://input"));
switch ($_GET['request']) {
    case 'asset-create':
        $response = createAsset((object) $_POST);
        echo json_encode($response);
        break;
    case 'asset-upload':
        $response = uploadAsset((object) $_GET);
        echo json_encode($response);
        break;
    case 'asset-status':
        if (!empty($_GET['asset_id'])) {
            $response = uploadStatus(sanitize_text_field($_GET['asset_id']));
            echo json_encode($response);
        }
        break;
    case 'labels-create':
        break;
    case 'labels-assign':
        break;
    case 'embed-code':
        $asset = new stdClass();
        $asset->embed_code = $path[1];