Jump to content

Recommended Posts

Posted

Hello i am trying to add native ad format by modifying asyncspc.php 

My idea is...i have pulled all the ads linked to a zone and shorted them by the campaign type and by priorities but in some point of time i realize that fetching ads from $GLOBALS['_MAX']['considered_ads']['0'] is not a good choice as there will be no OABLOCK,OACAP cookies will be there for capping..?

also found that (i may be wrong) $GLOBALS['_MAX'] is generated by MAX_adSelect function..?

so far what i have done is but no luck in getting OABLOCK,OACAP cookies working for all the selected ads

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;}}}
        }
        
    }

i have placed above code after echo json_encode($spc_output); ...above code is for override campaign...

can any body tell me what i am doing wrong or what should i do to get it working in proper way..?

  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...