网站建设中的整合订单系统openx2.8.X改造工程,我们只是把openx简陋的排期diy了一下,但是,往往在公司运用中。尤其是广告投放这一块,一个openx满足不了需求。
我们总想自己定制一个满足自己的一套广告系统,下面我谈谈我的做法:
那么怎么用我们自己开发的订单系统,操作openx呢。其实实现的方法有很多,我这里介绍一下我的方法,我是在数据库层面上打通的,也就是订单系统直接向openx数据库插入数据;然后用openx生成的广告链接去投放到页面上,道理很简单,先看草图:
关键问题就是中间的接口部分,这个接口要负责接收你订单系统的信息,然后处理,在插入到openx对应的表中,然后用最后生成的代码,布置到页面上。
首先,我们先了解这个接口要处理openx的几张表,他们的关系。
const OX_TABLE_ZONES = 'ox_zones'; //版位表 const OX_TABLE_BANNERS = 'ox_banners'; //广告表 const OX_TABLE_CLIENTS = 'ox_clients'; //广告主表 const OX_TABLE_CAMPAIGNS = 'ox_campaigns'; //项目表 const OX_TABLE_ZONESASSOC= 'ox_ad_zone_assoc '; //版位广告关系表 const OX_TABLE_AGENCY = 'ox_agency'; //代理商(管理员)表 const OX_TABLE_AFFILIATES= 'ox_affiliates'; //网站表
在写这个接口之前,必须要了解到以上几个表对应的关系,其实openx的投放,全在这几个表中,掌握了这几个表的关系,投放逻辑就不用去看了。
这里只提供这个接口中,对于广告(创意)处理的方法。
public function getBannersData($action , $bannerid , $campaignid , $contenttype , $storagetype , $filename='' , $imageurl='' , $width , $height , $weight , $target , $url , $alt , $statustext , $bannertext , $description , $comments , $updated , $keyword){ $updated = $updated ? $updated=0 : $updated=date("Y-m-d G:i:s"); $dataArray = array( 'bannerid' => $bannerid, 'campaignid' => $campaignid, 'contenttype' => $contenttype, 'pluginversion' => 0, 'storagetype' => $storagetype, 'filename' => $filename, 'imageurl' => $imageurl, 'htmltemplate' => null, 'htmlcache' => null, 'width' => $width, 'height' => $height, 'weight' => $weight, 'seq' => 0, 'target' => $target, 'url' => $url, 'alt' => $alt, 'statustext' => $statustext, 'bannertext' => $bannertext, 'description' => $description, 'adserver' => '', 'block' => 0, 'capping' => 0, 'session_capping' => 0, 'compiledlimitation' => '', 'acl_plugins' => null, 'append' => '', 'bannertype' => null, 'alt_filename' => '', 'alt_imageurl' => '', 'alt_contenttype' => '', 'comments' => $comments, 'updated' => $updated, 'keyword' => $keyword, 'transparent' => 0, 'parameters' => 'N;', 'an_banner_id' => null, 'as_banner_id' => null, 'status' => 0, 'ad_direct_status' => 0, 'ad_direct_rejection_reason_id' => 0, 'ext_bannertype' => null, 'prepend' => '' ); if($action == 'add'){ $this->insert(self::OX_TABLE_BANNERS, $dataArray); //return $this->addRelation('add' , $bannerid);//当插入一条广告后,不自动插入对应关系时启用 }else if($action == 'update'){ $condition = "bannerid = $bannerid"; $this->update(self::OX_TABLE_BANNERS, $dataArray , $condition); } }
以上就是接口中,对于广告信息的插入和更新
PS:openx的投放逻辑中,你投放了一个广告后,它会在ox_ad_zone_assoc版位广告关系表中,插入该广告的部分信息,去表中看一下,关系就看到了。
测试一下,向ox_banaer表中插入一下数据:
$obj->getBannersData('add' , 9 , 11 , 'jpeg' , 'web' , '111.jpg' , 100 , 100 , 1 , '_blank' , 'www.haibao.cn' , '海报' , '321' , '1111' , '给ID为11的项目添加一个广告' , '给ID为11的项目添加一个广告' , $updated , '雅斯兰德 小贝 小S');
最后,接口开发出来以后,模仿openx投放的逻辑,调你自己的这个接口向openx插入这些必要的元素;最后用openx生成的广告链接布置到模板中;如果广告生效,证明接口没问题。那么接下来就是订单系统与你接口的数据匹配问题了。这就根据自己公司,自己需求模式来定吧。