Welcome Guest, Not a member yet? Register   Sign In
openX addbanner HELP!!
#1

[eluser]Unknown[/eluser]
anyone of this forum can help me on how to add banner using the openx api for codeigniter..
i can add advertiser and campaign using this code:
/*advertiser*/
$advertiser = array(
"advertiserName"=>'tiser12',
"contactName"=>'contact1',
"emailAddress"=>'[email protected]'
);
$advertiserId = $this->openx->addAdvertiser($advertiser);
/*Campaign*/
$campaign = array(
"advertiserId"=>$advertiserId,
"campaignName"=>'campaign1'
);
$campaignId = $this->openx->addCampaign($campaign);

how about for the banner..help please...thanks...
#2

[eluser]jmadsen[/eluser]
looking at the docs here:

http://www.ecliptik.net/en/openx.html

it seems you make a zone, then link the banner to it:

Code:
Add a new zone

$zone = array(
'publisherId'=> $publisher_id,
'zoneName' => $zone_name,
'type' => $type, //i.e. banner
'width' => $width,
'height' => $height
);

$zoneId = $this->openx->addZone($zone);
Link banner to a zone

$this->openx->linkBanner($zone_id, $banner_id);


give that a try and see if it works
#3

[eluser]Unknown[/eluser]
actually that is my reference in creating an advertiser and campaign but in that article it doesn't show on how to add a banner it only show on how to link a zone into a banner...all I want to know is on how to upload a banner using the openx api through codeigniter..

by the way...thanks for the reply...hoping for more replies...thanks
#4

[eluser]Phoz[/eluser]
Code:
$banner = array(
  'campaignId' => $campaignId,
  'storageType' => 'web',
  'aImage' => array(
    'filename' => $_FILES['banner']['name'],
    'content' => file_get_contents($_FILES['banner']['tmp_name'])
  )
);
$bannerId = $this->openx->addBanner($banner);

See http://www.openx.com/community/developers for reference and examples.

You might run into the error XML error: Invalid character at line 38. This has to do with the Openx library (Openx.php, around line 155) which recognizes $banner['aImage']['content'] as string which should be base64.

Look on the internet on how to determine if the $value is binary, so should be 'base64'. Working on this myself now.
#5

[eluser]Phoz[/eluser]
How I solved the XML error:

Create a custom class File.php and include this
Code:
<?php
class File {
  private $_filename;

  public function __construct($filename)
  {
    $this->_filename = $filename;
  }

  public function get_contents()
  {
    return file_get_contents($this->_filename);
  }
}

Set the image content variable like this:
Code:
'content' => new File($_FILES['banner']['tmp_name'])

Change the Openx.php code from line 151:
Code:
default :
  if(is_object($value))
    switch (get_class($value))
    {
      case 'DateTime':
        return array($value->format("Ymd"), 'dateTime.iso8601');
        break;
    case 'File':
      return array($value->get_contents(), 'base64');
      break;
    }
    else
      return array($value, 'string');
break;




Theme © iAndrew 2016 - Forum software by © MyBB