LogIn
 

The platform APIs are used to place advertisements into your web page or mobile application. The various ways of including advertisements all need a publisher id that is obtained from the Mobile Advert Network publisher screen. A publisher id looks something like this: 91beda0f_4477_4a93_9130_291b02bbc933.

Supported Platforms:

Static Non Changing web Pages (xhtml or wml)

This is the quickest and simplest way to integrate Mobile Advert Network advertisements. Just place the following HTML into your existing mobile page:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • This method of showing advertisements relies on the end users' browser supporting Javascript. Some older and less capable phone don't have Javascript and some users may have turned off Javascript. A more reliable way of including advertisements is using php, cgi, jsp, classic asp, c# or vb to create the web page dynamically.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

php

Place the following code into your existing page:


<?php
// Your publisher id
$man_pid = "YOURID";

// Select your platform here (xhtml or wml)
$man_platform = "xhtml";

// Test mode (when set to 1) shows some test adverts
//$man_test = "1";
$man_test = "";

$man_headers = urlencode($_SERVER["HTTP_USER_AGENT"])."\n".urlencode($_SERVER["HTTP_ACCEPT"])."\n";
$man_ip = urlencode($_SERVER["REMOTE_ADDR"]);

$man_url = "http://mobileadvertnetwork.com/man.dll?api&pid=$man_pid&m=$man_platform&t=$man_test&i=$man_ip&h=$man_headers";

@$man_response = file_get_contents($man_url);
echo $man_response != FALSE ? $man_response : "";
?>
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • The $man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set $man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

cgi (perl)

Place the following code into your existing page:

use URI::URL;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTTP::Request::Common;

# Remove this if you have already done it
print "content-type: text/html \n\n";

# Your publisher id
$man_pid = "
YOURID";

# Select your platform here (xhtml or wml)
$man_platform = "xhtml";

# Test mode (when set to 1) shows some test adverts
#$man_test = "1";
$man_test = "";

$man_headers = URI::URL->new($ENV{'HTTP_USER_AGENT'})."\n".URI::URL->new($ENV{'HTTP_ACCEPT'})."\n";
$man_ip = URI::URL->new($ENV{'REMOTE_ADDR'});

$man_url = "http://mobileadvertnetwork.com/man.dll?api&pid=$man_pid&m=$man_platform&t=$man_test&i=$man_ip&h=$man_headers";
$man_ua = LWP::UserAgent->new();
$man_ua->timeout( 6 );
$man_response = $man_ua->request(GET "$man_url");

if($man_response->is_error()) 
{
print("");
}
else 
{
print($man_response->content());
}
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • The $man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set $man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

jsp

Place the following code into your existing page:

<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.net.URL" %>

<%@ page import="java.net.URLEncoder" %>

<%
// Your publisher id
String man_pid = "
YOURID";

// Select your platform here (xhtml or wml)
String man_platform = "xhtml";

// Test mode (when set to 1) shows some test adverts
//String man_test = "1";
String man_test = "";

String man_headers = request.getHeader("User-Agent") + "\n" + request.getHeader("Accept") + "\n";
String man_ip = request.getRemoteAddr();

try 
{
man_headers = URLEncoder.encode(man_headers, "UTF-8");
man_platform = URLEncoder.encode(man_platform, "UTF-8");
man_ip = URLEncoder.encode(man_ip, "UTF-8");

catch(Exception e) 

}

String man_url = "http://mobileadvertnetwork.com/man.dll?api&" + "pid=" + man_pid + "&m=" + man_platform + "&t=" + man_test + "&i=" + man_ip + "&h=" + man_headers;

String man_contents = "";
try 
{
URL url = new URL(man_url);
InputStream in = url.openStream();
InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine()) != null) 
{
man_contents += line;
}

catch(Exception e) 

}

out.println(man_contents);
%>
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • The man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

Classic ASP

Place the following code into your existing page:

<%
' Your publisher id
Dim man_pid
man_pid = "
YOURID"

' Select your platform here (xhtml or wml)
Dim man_platform
man_platform ="xhtml"

' Test mode (when set to 1) shows some test adverts
Dim man_test
man_test = ""
'man_test = "1"


Dim man_headers
man_headers = Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT") & "\n" & Request.ServerVariables("HTTP_ACCEPT") & "\n") 

Dim man_ip
man_ip = Server.URLEncode(Request.ServerVariables("REMOTE_ADDR"))

Dim man_url
man_url = "http://mobileadvertnetwork.com/man.dll?api&pid=" & man_pid & "&m=" & man_platform & "&t=" & man_test & "&i=" & man_ip & "&h=" & man_headers

Set Connection = Server.CreateObject("MSXML2.ServerXMLHTTP")
Connection.Open "get", man_url, True
Call Connection.Send()

On Error Resume Next

If Connection.readyState <> 4 Then
Connection.waitForResponse 5
End If

If Err.Number <> 0 Then
Response.write("")
ElseIf (Connection.readyState <> 4) Or (Connection.Status <> 200) Then
Connection.Abort
Response.write("")
Else
man_response = Connection.responseText
Response.write(man_response)
End If

Set Connection = Nothing
%> 
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • The man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

c# (.NET)

Place the following code into your existing page:

using System.Net;
using System.IO;
using System.Text;

// Your publisher id
string man_pid = "
YOURID";

// Select your platform here (xhtml or wml)
string man_platform = "xhtml";

// Test mode (when set to 1) shows some test adverts
//string man_test = "1";
string man_test = "";

string man_headers = Request.UserAgent + "\n" + Request.AcceptTypes + "\n";
string man_ip = Request.UserHostAddress;

string man_url = String.Format("http://mobileadvertnetwork.com/man.dll?api&pid={0}&m={1}&t={2}&i={3}&h={4}", man_pid, man_platform, man_test, man_ip, man_headers);
Uri man_uri = new Uri(man_url, false);

HttpWebRequest man_request = (HttpWebRequest)WebRequest.Create(man_uri);
HttpWebResponse man_response = (HttpWebResponse)man_request.GetResponse();
StreamReader man_reader = new StreamReader(man_response.GetResponseStream(), Encoding.UTF8);

string man_buffer = man_reader.ReadToEnd();
Response.Write(man_buffer);
man_reader.Close();
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • The man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

vb (.NET)

Place the following code into your existing page:

' Your publisher id
Dim man_pid = "
YOURID"

' Select your platform here (xhtml or wml)
Dim man_platform = "xhtml"

' Test mode (when set to 1) shows some test adverts
Dim man_test
man_test = ""
'man_test = "1"

Dim man_headers = Server.UrlEncode(Request.ServerVariables("HTTP_USER_AGENT") & "\n" & Request.ServerVariables("HTTP_ACCEPT") & "\n")

Dim man_ip = Server.UrlEncode(Request.ServerVariables("REMOTE_ADDR"))

Dim man_url = "http://mobileadvertnetwork.com/man.dll?api&pid=" & man_pid & "&m=" & man_platform & "&t=" & man_test & "&i=" & man_ip & "&h=" & man_headers

Dim man_connection = Server.CreateObject("MSXML2.ServerXMLHTTP") ' This needs <%@ Page aspcompat=true %>
man_connection.Open("get", man_url, True)
Call man_connection.Send()

On Error Resume Next

If man_connection.readyState <> 4 Then
man_connection.waitForResponse(5)
End If

If Err.Number <> 0 Then
Response.Write("")
ElseIf (man_connection.readyState <> 4) Or (man_connection.Status <> 200) Then
man_connection.Abort()
Response.Write("")
Else
Dim man_response
man_response = man_connection.responseText
Response.Write(man_response)
End If

man_connection = Nothing
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • You will need to set aspcompat='true'.
  • The man_platform is just used for targeting ads and doesn't affect the html written out to the user's browser. If you know you are just serving wml then set it to wml otherwise set to xhtml.
  • Set man_test to 1 to show test adverts.
  • You cannot test this on a normal PC web browser because adverts won't be displayed.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.

Symbian

In order that a user can click on advertising links, the links should be placed within a web page. This web page can either be viewed within the phone's browser or a web page can be embedded within a Symbian application as a Browser Control (CBrCtl). 

The quickest and simplest way to integrate Mobile Advert Network advertisements is to add the following HTML to the HTML displayed in your web page or by your browser control:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

This method of showing advertisements relies on the end users' browser supporting Javascript. Some users may have turned Javascript off. A more reliable way of including advertisements is to use the HTTP GET or POST interface to fetch the HTML using the HTTP Client API.

Apple iPhone

In order that a user can click on advertising links, the links should be placed within a web page. This web page can either be viewed within the phone's browser or a web page can be embedded within an Apple application as a UIWebView. 

The quickest and simplest way to integrate Mobile Advert Network advertisements is to add the following HTML to the HTML displayed by your web page or UIWebView:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

This method of showing advertisements relies on the end users' browser supporting Javascript. Some users may have turned Javascript off. A more reliable way of including advertisements is to use the HTTP GET or POST interface to fetch the HTML using the Networking and Internet frameworks and libraries.

BlackBerry

In order that a user can click on advertising links, the links should be placed within a web page. This web page can either be viewed within the phone's browser or a web page can be embedded within a BlackBerry application as a browser field (v5 version here). 

The quickest and simplest way to integrate Mobile Advert Network advertisements is to add the following HTML to the HTML displayed by your web page or browser field:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

This method of showing advertisements relies on the end users' browser supporting Javascript. Some users may have turned Javascript off. A more reliable way of including advertisements is to use the HTTP GET or POST interface to fetch the HTML using a HttpConnection.

Android

In order that a user can click on advertising links, the links should be placed within a web page. This web page can either be viewed within the phone's browser or a web page can be embedded within an Android application as a WebView

The quickest and simplest way to integrate Mobile Advert Network advertisements is to add the following HTML to the HTML displayed by your web page or WebView:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

This method of showing advertisements relies on the end users' browser supporting Javascript. Some users may have turned Javascript off. A more reliable way of including advertisements is to use the HTTP GET or POST interface to fetch the HTML using a HttpRequest.

Windows Mobile

In order that a user can click on advertising links, the links should be placed within a web page. This web page can either be viewed within the phone's browser or a web page can be embedded within an Android application as a HTMLControl (Win32) or WebBrowser (.NET).

The quickest and simplest way to integrate Mobile Advert Network advertisements is to add the following HTML to the HTML displayed by your web page, HTMLControl or WebBrowser:

<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js">
  • Remember to change YOURID to your publisher id obtained from the Mobile Advert Network publisher page.
  • If you don't see any adverts then it's likely an error message has been returned as a HTML comment.
  • By adding &t=1 to the src you can put the fetching of adverts into test mode:
<script type="text/javascript" src="http://www.mobileadvertnetwork.com/man.dll?api&pid=YOURID&m=js&t=1">

This method of showing advertisements relies on the end users' browser supporting Javascript. Some users may have turned Javascript off. A more reliable way of including advertisements is to use the HTTP GET or POST interface to fetch the HTML using a or WinInet (Win32) or HttpWebRequest (.NET).

HTTP GET or POST

This is the way all platform methods ultimately access the Mobile Advert Network to fetch advertisements. It can be used from any programming language to return HTML for advertisements.

The API supports both HTTP GET or POST.

URL: http://www.mobileadvertnetwork.com/man.dll?api

Arguments: (& separated)

pid Platform id (from MAN publisher screen) Mandatory
p Platform (see below). Used for advert targeting only. Doesn't affect output HTML. Optional
m Mode (wml or xhtml). Used for advert targeting only. Doesn't affect output HTML. Optional
t If set to 1 then shows test adverts. Optional
i IP address of the phone Optional
h Http headers Optional

e.g. A minimal request would be: http://www.mobileadvertnetwork.com/man.dll?api&pid=<YOURID>
Where YOURID is your publisher Id.

Currently supported platforms (p=) are shown in the MAN Advertiser screen.

Test Adverts

In test mode, the API always returns two links to mobileadvertnetwork.com:

Links:

Test Advert 1 
Test Advert 2

Error Messages

If the Mobile Advert Network receives invalid information, an error message is usually returned as a HTML comment.
Browse the source code for the web page or examine the returned HTML to view the error.
 

Home    About     Register     Platform APIs     The Rules     Privacy     Contact
 
    Copyright © 2010                              Created, owned and run by Simon Judge   Blog