ajaxloading openx с jquery и php

после долгого путешествия мне удалось загрузить мои объявления openx с помощью jQuery php.

Вам нужно

  1. openx-сервер и доступ к /{openxPath}/www/delivery/alocal.php.
  2. небольшая обертка, которая делает рекламный скрипт ajaxable
  3. ajax-loader

Третьей и самой простой частью является ajax-loader:

$(document).ready( function() { $.ajax({ url: "http://{urlToYourOpenxWrapper/adwrapper.php", type: "POST", data: {m:'f'}, // 'code' of ad to load async: false, dataType: 'html' }).done(function (answer) { $('#footerBanner').html(answer); }); }); 

Вторая часть немного сложна, может быть, не доказана в будущем. Но для 2.8.11 он работает. По соображениям безопасности я сделал сопоставление от символов до идентификаторов зоны. Я не знаю, действительно ли это необходимо.

adwrapper.php:

 define('MAX_PATH', 'pathToYoutOpenXServer'); if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) { if (!isset($phpAds_context)) { $phpAds_context = array(); } switch ($_POST["m"]) { case 'f': // code of the ad to load $zoneId = 12; $bannerTarget = 'footerBanner zone_' . $zoneId; $bannerCode = view_local('', 12, 0, 0, '', '', '0', $phpAds_context, ''); break; } // get banner id $regex = '/(.*)(ox_[^\']*)(.*)/'; preg_match($regex, $bannerCode['html'], $matches); $oxId = $matches[2]; // compile new insert code $replaceWith = '$("' . $oxId . '").after'; $banner = str_replace('document.write', $replaceWith, $bannerCode['html']); $banner = str_replace('<script type=\'text/javascript\' src=\'http://openx.lift-online.de/www/delivery/fl.js\'></script>' , '<!-- replaced -->' , $banner); // use a single object for each ad to prevent problem in multitasking $banner = str_replace('ox_swf', 'ox_swf_' . $zoneId, $banner); // sometime the oxId (unique Id???) is the same and than zones are mixed // so I append the zoneId to the oxId $banner = str_replace($oxId, $oxId . '_' . $zoneId, $banner); echo '<div class="' . $bannerTarget . '">' . $banner . '</div>'; } 

    Спасибо, работая над этим и терпит неудачу, но отличное решение от вас!

    Мне просто нужно использовать GET-запрос и добавить в php-обертку

     header("Access-Control-Allow-Origin: *"); header("Access-Control-Request-Method: GET");