Search code examples
iosactionscript-3ipudid

AS3 - iOS device UDID and IP access for Smaato integration?


I'm building a mobile game and wanted to make it free with a banner ad on the start screen. I was going to use Smaato but it seems according to their api that they require that I pass them the UDID and the device ip in the query string. Is there anyway to do that with Actionscript 3? The code I'm using is below but it only pulls in an ad and when that ad is clicked on it points to a 2x2 gif on Smaato's servers. I got this code out of a book titled "iOS Development with Flash" and it's only a few months old. Smaato's "support" guy is not much help. Am I trying to accomplish the impossible?

Has anyone accomplished Smaato ingratiation with AS3?

/* SMAATO Advertising Code for Start Page
var request:URLRequest = new URLRequest("http://soma.smaato.com/oapi/reqAd.jsp");
var variables:URLVariables = new URLVariables();
variables.adspace = "65741799";
variables.pub = "923842495";
//variables.devip = "127.0.0.1"; The book had this line but it's not right so I commented it out
variables.format = "IMG";
variables.adcount = "1";
variables.response = "XML";
request.data = variables;
var loader:URLLoader = new URLLoader();

var l:Loader = new Loader();

loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);


function onComplete(e:Event):void
{
    var data:XML = new XML(loader.data as String);
    var status:String = data.*::status.toString(); 
    if(status == "success")
    {
        var ad:XMLList = data.*::ads.*::ad;
        var link:String = ad.*::link.toString();

        var l:Loader = new Loader();
        l.load(new URLRequest(link));
        addChild(l);
        l.x = 80;
        l.y = 255;
        var clickurl:String = ad.*::action.@target.toString();
        l.addEventListener(MouseEvent.CLICK, onAdClick);
     }

   function onAdClick(e:MouseEvent):void
   {
       var request:URLRequest = new URLRequest(clickurl);
       navigateToURL(request);
   }
}

Thanks for any help you can offer.

Rich


Solution

  • If the requests are coming from a mobile directly (which is the case here because it's an app) the devIP is not mandatory. Also you can skip the UDID if it's not available. The adspacer.gif issue probably results in a user agent mismatch. Out support team will get back to you regarding this.

    Best, Michael (Smaato Inc.)