您好我正在尝试通过修改 asyncspc.php 添加原生广告格式
我的想法是......我已经拉出所有链接到一个区域的广告,并按活动类型和优先级缩短它们,但在某些时候我意识到从 $GLOBALS['_MAX']['considered_ads'] 获取广告['0'] 不是一个好的选择,因为没有OABLOCK,OACAP cookie 将用于封顶..?
还发现(我可能错了)$GLOBALS['_MAX'] 是由 MAX_adSelect 函数生成的..?
到目前为止,我所做的只是让 OABLOCK、OACAP cookie 适用于所有选定的广告,但没有运气
if (!empty($GLOBALS['_MAX']['considered_ads']['0']['xAds'])) {
$xAds=$GLOBALS['_MAX']['considered_ads']['0']['xAds'];
usort($xAds, function ($a, $b) {return $a['priority'] < $b['priority'];});
//print_r($xAds);
$native_output_xAds=array();
foreach ($xAds as $id => $value) {
// Total_Amount == $value['Total_Amount']
$ad_id=$value['ad_id'];
//echo $ad_id;
$aBanner=MAX_cacheGetAd($ad_id,true);// getting banner info from cache///check cache.php
if (empty($aBanner)) {
$aBanner=OA_Dal_Delivery_getAd($ad_id);// getting banner info from db///check delevery.php
}
$outputbuffer=MAX_adRender($aBanner, $zoneid);
//print_r($outputbuffer);
//print_r($aBanner);
$output = array(
'html' => $outputbuffer,
'bannerid' => $aBanner['ad_id'],
'contenttype' => $aBanner['contenttype'],
'alt' => $aBanner['alt'],
'width' => $aBanner['width'],
'height' => $aBanner['height'],
'url' => $aBanner['url'],
'campaignid' => $aBanner['placement_id'],
'clickUrl' => $aBanner['clickUrl'],
'logUrl' => $aBanner['logUrl'],
'aSearch' => $aBanner['aSearch'],
'aReplace' => $aBanner['aReplace'],
'bannerContent' => $aBanner['bannerContent'],
'clickwindow' => $aBanner['clickwindow'],
'aRow' => $aBanner,
'context' => _adSelectBuildContext($aBanner, $context),
'iframeFriendly' => (bool)$aBanner['iframe_friendly'],
);
// If ad-logging is disabled, the log beacon won't be sent, so set the capping at request
if (MAX_Delivery_cookie_cappingOnRequest()) {
if ($aBanner['block_ad'] > 0 || $aBanner['cap_ad'] > 0 ||$aBanner['session_cap_ad'] > 0) {
MAX_Delivery_cookie_setCapping('Ad', $aBanner['ad_id'], $aBanner['block_ad'], $aBanner['cap_ad'], $aBanner['session_cap_ad']);
}
if ($aBanner['block_campaign'] > 0 || $aBanner['cap_campaign'] > 0 || $aBanner['session_cap_campaign'] > 0) {
MAX_Delivery_cookie_setCapping('Campaign', $aBanner['placement_id'], $aBanner['block_campaign'], $aBanner['cap_campaign'], $aBanner['session_cap_campaign']);
}
// Store the last view action event om the cookie as well (if required)
MAX_Delivery_log_setLastAction(0, array($aBanner['ad_id']), array($zoneId), array($aBanner['viewwindow']));
}
//print_r($output);
$native_output_xAds[] = array(
'html' => $output['html'],
'width' => isset($output['width']) ? $output['width'] : 0,
'height' => isset($output['height']) ? $output['height'] : 0,
'iframeFriendly' => isset($output['iframeFriendly']) ? $output['iframeFriendly'] : false,
);
if (!empty($block) && !empty($output['ad_id'])) {
$output['context'][] = array('!=' => 'bannerid:' . $output['ad_id']);
}
if (!empty($blockcampaign) && !empty($output['campaignid'])) {
$output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
}
if (!empty($output['context'])) {
foreach ($output['context'] as $id => $contextArray) {
if (!in_array($contextArray, $context)) {
$context[] = $contextArray;}}}
}
}
我在 echo json_encode($spc_output); 之后放置了上面的代码 ...以上代码用于覆盖广告系列...
任何人都可以告诉我我做错了什么或者我应该怎么做才能让它以正确的方式工作..?