Ad Tag/ Install Code Samples

From Mojiva
Jump to: navigation, search

Contents

PHP Ad Tag/ Install Code

<?php

// change to "live" to disable demo mode and show real ads
define("MOJIVAV2_MODE", "live");

function mojivav2_ad()
{
    $ua = $_SERVER['HTTP_USER_AGENT'];
    $ip = (stristr($ua,"opera mini") && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
        ? trim(end(split(",", $_SERVER['HTTP_X_FORWARDED_FOR'])))
        : $_SERVER['REMOTE_ADDR'];

    // prepare url parameters of request
    $mojivav2_get  = 'site='.urlencode('85');
    $mojivav2_get .= '&ip='.urlencode($ip);
    $mojivav2_get .= '&ua='.urlencode($ua);
    $mojivav2_get .= '&url='.urlencode(sprintf("http%s://%s%s", (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == TRUE ? "s": ""), $_SERVER["HTTP_HOST"], $_SERVER["REQUEST_URI"]));
    $mojivav2_get .= '&zone='.urlencode('85');
    $mojivav2_get .= '&adstype=3'; // type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
    $mojivav2_get .= '&key=1';
    //$mojivav2_get .= '&lat=1';
    //$mojivav2_get .= '&long=1';
    $mojivav2_get .= '&count=1'; // quantity of ads
    $mojivav2_get .= '&version='.urlencode('php_0001'); // php code version
    $mojivav2_get .= '&keywords='; // keywords to search ad delimited by commas (not necessary)
    $mojivav2_get .= '&over_18=0'; // filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
    $mojivav2_get .= '&paramBORDER='.urlencode('#000000'); // ads border color
    $mojivav2_get .= '&paramHEADER='.urlencode('#cccccc'); // header color
    $mojivav2_get .= '&paramBG='.urlencode('#eeeeee'); // background color
    $mojivav2_get .= '&paramTEXT='.urlencode('#000000'); // text color
    $mojivav2_get .= '&paramLINK='.urlencode('#ff0000'); // url color


    //check UID
    if ( isset($_COOKIE['MOJIVA_AD_UDID']) ) {
        if(setcookie('MOJIVA_AD_UDID', $_COOKIE['MOJIVA_AD_UDID'], time() + 60 * 60 * 24 * 7)) {
            $mojivav2_get .= '&udid='.urlencode($_COOKIE['MOJIVA_AD_UDID']);
        }
    } else {
        $udid = md5(time()+rand());
        if(setcookie('MOJIVA_AD_UDID', $udid, time() + 60 * 60 * 24 * 7)) {
            $mojivav2_get .= '&udid='.urlencode($udid);
        }
    }


    if(MOJIVAV2_MODE == "test") $mojivav2_get .= '&test=1';

    // send request
    $mojivav2_request = @fsockopen('ads.mojiva.com', 80, $errno, $errstr, 1);
    if ($mojivav2_request) {
        stream_set_timeout($mojivav2_request, 3000);
        $query = "GET /ad?".$mojivav2_get." HTTP/1.0\r\n";
        $query .= "Host: ads.mojiva.com\r\n";
        $query .= "Connection: close\r\n";


        // IIS support
        if(isset($_SERVER['ALL_HTTP']) && is_array($_SERVER['ALL_HTTP'])) {
            foreach ($_SERVER['ALL_HTTP'] as $name => $value) {
                $query .= "CS_$name: $value\r\n";
            }
        }
        elseif(isset($_SERVER['ALL_HTTP'])) {
            $array = explode("\n",$_SERVER['ALL_HTTP']);
            foreach ($array as $value) {
                if($value) {
                    $query .= "CS_$value\r\n";
                }
            }
        }

        foreach ($_SERVER as $name => $value) {
            $query .= "CS_$name: $value\r\n";
        }

        $query .= "\r\n";
        fwrite($mojivav2_request, $query);
        $mojivav2_info = stream_get_meta_data($mojivav2_request);
        $mojivav2_timeout = $mojivav2_info['timed_out'];
        $mojivav2_contents = "";
        $mojivav2_body = false;
        $mojivav2_head = "";
        while (!feof($mojivav2_request) && !$mojivav2_timeout) {
            $mojivav2_line = fgets($mojivav2_request);
            if(!$mojivav2_body && $mojivav2_line == "\r\n") $mojivav2_body = true;
            if(!$mojivav2_body) $mojivav2_head .= $mojivav2_line;
            if($mojivav2_body && !empty($mojivav2_line)) $mojivav2_contents .= $mojivav2_line;
            $mojivav2_info = stream_get_meta_data($mojivav2_request);
            $mojivav2_timeout = $mojivav2_info['timed_out'];
        }
        fclose($mojivav2_request);
        if (!preg_match('/^HTTP\/1\.\d 200 OK/', $mojivav2_head)) $mojivav2_timeout = true;
        if($mojivav2_timeout) return "";
        return $mojivav2_contents;
    }
}

?>
<?php

// copy this snippet elsewhere on your page for display more of ads
echo mojivav2_ad();

?>


PHP CURL Ad Tag/ Install Code

<?php

// change to "live" to disable demo mode and show real ads
define("MOJIVAV2_MODE", "test");

function mojivav2_ad()
{
    $ua = $_SERVER['HTTP_USER_AGENT'];
    $ip = (stristr($ua,"opera mini") && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
        ? trim(end(split(",", $_SERVER['HTTP_X_FORWARDED_FOR'])))
        : $_SERVER['REMOTE_ADDR'];

    // prepare url parameters of request
    $mojivav2_get  = 'site='.urlencode('85');
    $mojivav2_get .= '&ip='.urlencode($ip);
    $mojivav2_get .= '&ua='.urlencode($ua);
    $mojivav2_get .= '&url='.urlencode(sprintf("http%s://%s%s", (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == TRUE ? "s": ""), $_SERVER["HTTP_HOST"], $_SERVER["REQUEST_URI"]));
    $mojivav2_get .= '&zone='.urlencode('85');
    $mojivav2_get .= '&adstype=3'; // type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
    $mojivav2_get .= '&key=1';
    //$mojivav2_get .= '&lat=1';
    //$mojivav2_get .= '&long=1';
    $mojivav2_get .= '&count=1'; // quantity of ads
    $mojivav2_get .= '&keywords='; // keywords to search ad delimited by commas (not necessary)
    $mojivav2_get .= '&over_18=0'; // filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
    $mojivav2_get .= '&paramBORDER='.urlencode('#000000'); // ads border color
    $mojivav2_get .= '&paramHEADER='.urlencode('#cccccc'); // header color
    $mojivav2_get .= '&paramBG='.urlencode('#eeeeee'); // background color
    $mojivav2_get .= '&paramTEXT='.urlencode('#000000'); // text color
    $mojivav2_get .= '&paramLINK='.urlencode('#ff0000'); // url color

    //check UID
    if ( isset($_COOKIE['MOJIVA_AD_UDID']) ) {
        if(setcookie('MOJIVA_AD_UDID', $_COOKIE['MOJIVA_AD_UDID'], time() + 60 * 60 * 24 * 7)) {
            $mojivav2_get .= '&udid='.urlencode($_COOKIE['MOJIVA_AD_UDID']);
        }
    } else {
        $udid = md5(time()+rand());
        if(setcookie('MOJIVA_AD_UDID', $udid, time() + 60 * 60 * 24 * 7)) {
            $mojivav2_get .= '&udid='.urlencode($udid);
        }
    }

    if(MOJIVAV2_MODE == "test") $mojivav2_get .= '&test=1';

    $sc_headers = array();
    foreach ($_SERVER as $name => $value) {
        $sc_headers[] = "CS_$name: $value";
    }

    // send request
    $url="http://ads.mojiva.com:80/ad?".$mojivav2_get;
    $timeout=3; //timeout in seconds
    $ch  = curl_init($url);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $sc_headers);
    $html=@curl_exec($ch);
    @curl_close($ch);
    if($html!==false) return $html;
    else return "";

}

?>
<?php

// copy this snippet elsewhere on your page for display more of ads
echo mojivav2_ad();


?>

JSP Ad Tag/ Install Code

<%@ page import="java.util.*,java.io.*,java.net.*, java.security.*, java.math.*" %>
<%
// copy this snippet elsewhere on your page for display more of ads
out.print(mojivav2_ad(request));

%>
<%!

// change to "live" to disable demo mode and show real ads
private static final String MOJIVAV2_MODE = "test";

private String mojivav2_ad(HttpServletRequest request)
{
    StringBuilder mojivav2_contents = new StringBuilder();
    try {

        // prepare url parameters of request
        StringBuilder mojivav2_get = new StringBuilder();
        mojivav2_get.append("site=").append("85");
        mojivav2_get.append("&ua=").append(URLEncoder.encode(request.getHeader("User-Agent"), "UTF-8"));
        mojivav2_get.append("&ip=").append(URLEncoder.encode(request.getRemoteAddr(),"UTF-8"));
        mojivav2_get.append("&url=").append(URLEncoder.encode(request.getRequestURL().toString(), "UTF-8"));
        mojivav2_get.append("&zone=").append("85");
        mojivav2_get.append("&adstype=3"); // type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
        mojivav2_get.append("&key=1");
        //mojivav2_get.append("&lat=1");
        //mojivav2_get.append("&long=1");
        mojivav2_get.append("&keywords="); // keywords to search ad delimited by commas (not necessary)
        mojivav2_get.append("&country="); // country of visitor
        mojivav2_get.append("&region="); // region of visitor
        mojivav2_get.append("&size_required=0"); // if img size attributes are required
        mojivav2_get.append("&paramBORDER=").append(URLEncoder.encode("#000000", "UTF-8")); // ads border color
        mojivav2_get.append("&paramHEADER=").append(URLEncoder.encode("#cccccc", "UTF-8")); // header color
        mojivav2_get.append("&paramBG=").append(URLEncoder.encode("#eeeeee", "UTF-8")); // background color
        mojivav2_get.append("&paramTEXT=").append(URLEncoder.encode("#000000", "UTF-8")); // text color
        mojivav2_get.append("&paramLINK=").append(URLEncoder.encode("#ff0000", "UTF-8")); // url color

        if(MOJIVAV2_MODE.equals("test")) mojivav2_get.append("&test=1");
        // send request
        BufferedReader mojivav2_reader = null;
        try {
            URL mojivav2_url = new URL("http://ads.mojiva.com:80/ad");
            HttpURLConnection mojivav2_request = (HttpURLConnection)mojivav2_url.openConnection();
            mojivav2_request.setRequestMethod("POST");
            mojivav2_request.setDoOutput(true);
            mojivav2_request.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            mojivav2_request.setRequestProperty("Content-Length", Integer.toString(mojivav2_get.length()));
            Enumeration e = request.getHeaderNames();
            if(e != null && e.hasMoreElements()) {
                while(e.hasMoreElements()) {
                   String hdr = (String) e.nextElement();
                   mojivav2_request.addRequestProperty("ch_"+hdr,request.getHeader(hdr));
                }
            }
            mojivav2_request.setConnectTimeout(3000);
            mojivav2_request.setReadTimeout(3000);
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(mojivav2_request.getOutputStream()));
            writer.write(mojivav2_get.toString());
            writer.close();
            mojivav2_reader = new BufferedReader(new InputStreamReader(mojivav2_request.getInputStream()));
            for (String line = null; (line = mojivav2_reader.readLine()) != null;)
                mojivav2_contents.append(line);
        } catch(java.net.SocketTimeoutException ste) {
              mojivav2_contents.append("");
        } catch (Exception e) {

        } finally {
            try {
                if(mojivav2_reader != null) {
                    mojivav2_reader.close();
                }
            } catch(Exception e) {

            }
        }
    } catch(Exception ex) {

    }
    return mojivav2_contents.toString();
}
%>

ASP install code

<%
'copy this snippet elsewhere on your page for display more of ads
Response.Write(mojivav2Ad())

%>

<script runat="server" language="vbs">
    Function mojivav2Ad()

        'change to "live" to disable demo mode and show real ads
        Dim MOJIVAV2_MODE
        MOJIVAV2_MODE = "test"

        'prepare url parameters of request
        On Error Resume Next
        Dim mojivav2_page_url
        If (Request.ServerVariables("HTTPS") = "off") Then mojivav2_page_url = "http://" Else mojivav2_page_url = "https://" End If
        mojivav2_page_url = mojivav2_page_url & Request.ServerVariables("HTTP_HOST")
        mojivav2_page_url = mojivav2_page_url & Request.ServerVariables("PATH_INFO")
        Dim mojivav2_get
        mojivav2_get = "site=" & "85"
        mojivav2_get = mojivav2_get & "&ua=" & Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))
        mojivav2_get = mojivav2_get & "&ip=" & Server.URLEncode(Request.ServerVariables("REMOTE_ADDR"))
        mojivav2_get = mojivav2_get & "&url=" & Server.URLEncode(mojivav2_page_url)
        mojivav2_get = mojivav2_get & "&zone=85"
        mojivav2_get = mojivav2_get & "&adstype=3" 'type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
        mojivav2_get = mojivav2_get & "&key=1"
        'mojivav2_get = mojivav2_get & "&lat=1"
        'mojivav2_get = mojivav2_get & "&long=1"
        mojivav2_get = mojivav2_get & "&keywords=" ' keywords to search ad delimited by commas (not necessary)
        mojivav2_get = mojivav2_get & "&over_18=0" 'filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
        mojivav2_get = mojivav2_get & "&count=1" 'quantity of ads
        mojivav2_get = mojivav2_get & "&paramBORDER=" & Server.URLEncode("#000000") 'ads border color
        mojivav2_get = mojivav2_get & "&paramHEADER=" & Server.URLEncode("#cccccc") 'header color
        mojivav2_get = mojivav2_get & "&paramBG=" & Server.URLEncode("#eeeeee") 'background color
        mojivav2_get = mojivav2_get & "&paramTEXT=" & Server.URLEncode("#000000") 'text color
        mojivav2_get = mojivav2_get & "&paramLINK=" & Server.URLEncode("#ff0000") 'url color
        
        If MOJIVAV2_MODE = "test" Then mojivav2_get = mojivav2_get & "&test=1" End If

        'send request
        Response.Buffer = True
        Dim mojivav2_request
        Set mojivav2_request = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
        mojivav2_request.setTimeouts 3000, 3000, 3000, 3000
        mojivav2_request.Open "GET", "http://ads.mojiva.com:80/ad", False
        mojivav2_request.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
        mojivav2_request.Send mojivav2_get
        mojivav2Ad = mojivav2_request.responseText
        Set mojivav2_request = Nothing
        Err.clear
        If Err.number <> 0 Then
          mojivav2Ad = ""
        End If
    End Function
</script>

CGI/PERL Ad Tag/ Install Code

use LWP::UserAgent;
use URI::URL;

# copy this snippet elsewhere on your page for display more of ads
print mojivav2_ad();

sub mojivav2_ad
{
    # change to "live" to disable demo mode and show real ads
    my $mojivav2_mode = 'test';

    # prepare url parameters of request
    my $mojivav2_page_url = sprintf('http%s://%s%s',($ENVHTTPS ne '' ? 's': ''), $ENVHTTP_HOST, $ENVREQUEST_URI);
    my %mojivav2_get = (
        'site'        => 85,
        'ua'          => $ENVHTTP_USER_AGENT,
        'ip'          => $ENVREMOTE_ADDR,
        'url'         => $mojivav2_page_url,
        'zone'        => '85',
        'adstype'     => '3', # type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
        'key'         => '1',
        #'lat'         => '1',
        #'long'         => '1',
        'count'       => '1',
        'keywords'    => "", # keywords to search ad delimited by commas (not necessary)
        'over_18'     => '0', # filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
        'paramBORDER' => '#000000', # ads border color
        'paramHEADER' => '#cccccc', # header color
        'paramBG'     => '#eeeeee', # background color
        'paramTEXT'   => '#000000', # text color
        'paramLINK'    => '#ff0000', # url color

    );

    $mojivav2_gettest = '1' if($mojivav2_mode eq 'test');

    # send request
    my $mojivav2_uri = URI::URL->new("http://ads.mojiva.com:80/ad");
    my $mojivav2_request = LWP::UserAgent->new;
    $mojivav2_request->timeout(3);
    my $mojivav2_response = $mojivav2_request->post($mojivav2_uri, \%mojivav2_get);
    if ($mojivav2_response->is_error()) {
        return "";
    } else {
        return $mojivav2_response->content();
    }
}

VB.NET Ad Tag/ Install Code

<%
    'copy this snippet elsewhere on your page for display more of ads
    Response.Write(mojivav2_ad())

%>

<script runat="server">
    Function mojivav2_ad() As String

        'change to "live" to disable demo mode and show real ads
        Dim MOJIVAV2_MODE As String = "test"

        'prepare url parameters of request
        Dim mojivav2_get As StringBuilder = New StringBuilder()
        mojivav2_get.Append("site=").Append("85")
        mojivav2_get.Append("&ua=").Append(HttpUtility.UrlEncode(Request.UserAgent, Encoding.UTF8))
        mojivav2_get.Append("&ip=").Append(HttpUtility.UrlEncode(Request.UserHostAddress, Encoding.UTF8))
        mojivav2_get.Append("&url=").Append(HttpUtility.UrlEncode(Request.Url.ToString(), Encoding.UTF8))
        mojivav2_get.Append("&zone=").Append(HttpUtility.UrlEncode("85", Encoding.UTF8))
        mojivav2_get.Append("&adstype=3") 'type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
        mojivav2_get.Append("&keywords=") ' keywords to search ad delimited by commas (not necessary)
        mojivav2_get.Append("&whitelabel=0") ' filter by whitelabel(0 - all, 1 - only whitelabel, 2 - only non-whitelabel)
        mojivav2_get.Append("&premium=0") ' filter by premium status (0 - non-premium, 1 - premium only, 2 - both)
        mojivav2_get.Append("&over_18=0") ' filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
        mojivav2_get.Append("&key=1")
        'mojivav2_get.Append("&lat=1")
        'mojivav2_get.Append("&long=1")
        mojivav2_get.Append("&count=1") 'quantity of ads
        mojivav2_get.Append("&paramBORDER=").Append(HttpUtility.UrlEncode("#000000", Encoding.UTF8)) 'ads border color
        mojivav2_get.Append("&paramHEADER=").Append(HttpUtility.UrlEncode("#cccccc", Encoding.UTF8)) 'header color
        mojivav2_get.Append("&paramBG=").Append(HttpUtility.UrlEncode("#eeeeee", Encoding.UTF8)) 'background color
        mojivav2_get.Append("&paramTEXT=").Append(HttpUtility.UrlEncode("#000000", Encoding.UTF8)) 'text color
        mojivav2_get.Append("&paramLINK=").Append(HttpUtility.UrlEncode("#ff0000", Encoding.UTF8)) 'url color


        If MOJIVAV2_MODE = "test" Then mojivav2_get.Append("&test=1")

        'send request
        Dim mojivav2_contents As StringBuilder = New StringBuilder()
        Try
            Dim mojivav2_get_bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(mojivav2_get.ToString)
            Dim mojivav2_request As System.Net.WebRequest = System.Net.WebRequest.Create("http://ads.mojiva.com:80/ad")
            mojivav2_request.Method = "POST"
            mojivav2_request.ContentType = "application/x-www-form-urlencoded"
            mojivav2_request.ContentLength = mojivav2_get_bytes.Length()
            mojivav2_request.Timeout = 3000
            Dim mojivav2_os As System.IO.Stream = mojivav2_request.GetRequestStream()
            mojivav2_os.Write(mojivav2_get_bytes, 0, mojivav2_get_bytes.Length())
            mojivav2_os.Close()
            Dim mojivav2_response As System.Net.HttpWebResponse = CType(mojivav2_request.GetResponse, System.Net.HttpWebResponse)
            Dim mojivav2_ios As System.IO.Stream = mojivav2_response.GetResponseStream()
            Dim mojivav2_reader As System.IO.StreamReader = New System.IO.StreamReader(mojivav2_ios)
            mojivav2_contents.Append(mojivav2_reader.ReadToEnd())
        Catch mojivav2_e As Exception
            mojivav2_contents.Append("")
        End Try
        Return mojivav2_contents.ToString()
    End Function
</script>

C# Ad Tag/ Install Code

<%
// copy this snippet elsewhere on your page for display more of ads
Response.Write(mojivav2_ad());

%>
<script runat="server">

// change to "live" to disable demo mode and show real ads
const string MOJIVAV2_MODE = "test";

string mojivav2_ad()
{
    // prepare url parameters of request
    StringBuilder mojivav2_get = new StringBuilder();
    mojivav2_get.Append("site=").Append("85");
    mojivav2_get.Append("&ua=").Append(HttpUtility.UrlEncode(Request.UserAgent, Encoding.UTF8));
    mojivav2_get.Append("&ip=").Append(HttpUtility.UrlEncode(Request.UserHostAddress, Encoding.UTF8));
    mojivav2_get.Append("&url=").Append(HttpUtility.UrlEncode(Request.Url.ToString(), Encoding.UTF8));
    mojivav2_get.Append("&zone=").Append(HttpUtility.UrlEncode("85", Encoding.UTF8));
    mojivav2_get.Append("&adstype=3"); // type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
    mojivav2_get.Append("&key=1");
    //mojivav2_get.Append("&lat=1");
    //mojivav2_get.Append("&long=1");
    mojivav2_get.Append("&keywords="); // keywords to search ad delimited by commas (not necessary)
    mojivav2_get.Append("&over_18=0"); // filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
    mojivav2_get.Append("&count=1"); // quantity of ads
    mojivav2_get.Append("&paramBORDER=").Append(HttpUtility.UrlEncode("#000000", Encoding.UTF8)); // ads border color
    mojivav2_get.Append("&paramHEADER=").Append(HttpUtility.UrlEncode("#cccccc", Encoding.UTF8)); // header color
    mojivav2_get.Append("&paramBG=").Append(HttpUtility.UrlEncode("#eeeeee", Encoding.UTF8)); // background color
    mojivav2_get.Append("&paramTEXT=").Append(HttpUtility.UrlEncode("#000000", Encoding.UTF8)); // text color
    mojivav2_get.Append("&paramLINK=").Append(HttpUtility.UrlEncode("#ff0000", Encoding.UTF8)); // url color

    if (MOJIVAV2_MODE == "test") mojivav2_get.Append("&test=1");

    // send request
    StringBuilder mojivav2_contents = new StringBuilder();
    try {
        byte[] mojivav2_get_bytes = System.Text.Encoding.UTF8.GetBytes(mojivav2_get.ToString());
        System.Net.WebRequest mojivav2_request  = System.Net.WebRequest.Create("http://ads.mojiva.com:80/ad");
        mojivav2_request.Method = "POST";
        mojivav2_request.ContentType = "application/x-www-form-urlencoded";
        mojivav2_request.ContentLength = mojivav2_get_bytes.Length;
        mojivav2_request.Timeout = 3000;
        System.IO.Stream mojivav2_os = mojivav2_request.GetRequestStream();
        mojivav2_os.Write(mojivav2_get_bytes, 0, mojivav2_get_bytes.Length);
        mojivav2_os.Close();
        System.Net.HttpWebResponse mojivav2_response = (System.Net.HttpWebResponse)mojivav2_request.GetResponse();
        System.IO.StreamReader mojivav2_reader = new System.IO.StreamReader(mojivav2_response.GetResponseStream());
        mojivav2_contents.Append(mojivav2_reader.ReadToEnd().Trim());
    } catch (Exception) {
        mojivav2_contents.Append("");
    }
    return mojivav2_contents.ToString();
}
</script>

Ruby on Rails Ad Tag/ Install Code

<%
require 'net/http'
require 'uri'
require 'md5'

def mojivav2_ad(request)

    # change to "live" to disable demo mode and show real ads
    mojivav2_mode   = "test"

    # prepare url parameters of request
    mojivav2_get = {}
    mojivav2_get["site"]           = "7057"
    mojivav2_get["ua"]          = request.user_agent
    mojivav2_get["ip"]          = request.remote_ip
    mojivav2_get["url"]         = request.request_uri
    mojivav2_get["zone"]        = "12310"
    mojivav2_get["adstype"]     = "3" # type of ads (1 - text only, 2 - images only, 3 - text + images, 6 - sms)
    mojivav2_get["key"]         = "1"
    #mojivav2_get["lat"]         = "1"
    #mojivav2_get["long"]         = "1"
    mojivav2_get["keywords"]    = ""  # keywords to search ad delimited by commas (not necessary)
    mojivav2_get["over_18"]     = "0" # filter by ad over 18 content (0 or 1 - deny over 18 content , 2 - only over 18 content, 3 - allow all ads including over 18 content)
    mojivav2_get["count"]       = "1" # quantity of ads
    mojivav2_get["paramBORDER"] = "#000000" # ads border color
    mojivav2_get["paramHEADER"] = "#cccccc" # header color
    mojivav2_get["paramBG"]     = "#eeeeee" # background color
    mojivav2_get["paramTEXT"]   = "#000000" # text color
    mojivav2_get["paramLINK"]   = "#ff0000" # url color

  
    mojivav2_get["test"]        = "1" if mojivav2_get == "test"

    # send request
    begin
        mojivav2_uri = URI.parse("http://ads.mojiva.com:80/ad")
        mojivav2_request = Net::HTTP::Post.new(mojivav2_uri.path)
        mojivav2_request.set_form_data(mojivav2_get)
        mojivav2_conn = Net::HTTP.new(mojivav2_uri.host, mojivav2_uri.port)
        mojivav2_conn.read_timeout = 3.0
        mojivav2_conn.open_timeout = 3.0
        mojivav2_response = mojivav2_conn.start {|mojivav2_http| mojivav2_http.request(mojivav2_request) }
        mojivav2_contents = mojivav2_response.body
    rescue Timeout::Error => te
        mojivav2_contents = ""
    rescue
        end
    mojivav2_contents
end
%>
<%=
    # copy this snippet elsewhere on your page for display more of ads
    mojivav2_ad(request)
%>

JS Ad Tag/ Install Code

Javascript Ad Serving API

Include in the head of your page:

<script src='http://www.mojiva.com/js/mobile.js'></script>

Then, in any place you want an ad to appear, paste this code:

<script>
AdRequest_({
   site:85,
   zone:85,
   type:6,
   min_size_x:0,
   min_size_y:0,
   size_x:320,
   size_y:50,
   clickPrepend:'',
   pixelURL:''
});
</script>

Explanation:

1) site and zone: publisher identifiers

2) type: Type of ads to be returned (1 - text, 2 - image, 4 - richmedia ad). You can set different combinations with these values. For example, 3 = 1 + 2 (text + image), 7 = 1 + 2 + 4 (text + image + richmedia) and so on. Default value is ’-1’ that means any type of ads can be returned. 3) target: The link target; set to "_blank" if you want the clicked ad to open in a new window

4) defaultHtml: content to be displayed if no ad comes back from the server.

5) clickPrepend: whatever is here will be added verbatim to the beginning of all clickable urls.

6) pixelUrl: If this is set, the ad will make a call to the url when the ad is shown.

7) size parameters: Please see http://developer.mojiva.com/Mojiva_Ad_Request_API_/_Implementation#Custom_Ad_Sizes

XHTML/WML Ad Tag/ Install Code

<div><a href="http://ads.mojiva.com/redir?dkey=#RANDOM#"><img src="http://ads.mojiva.com/ad?zone=12310&type=2&dkey=#RANDOM#"/></a></div>

Please replace #RANDOM# above with a random number for cache bursting.


Personal tools
Namespaces

Variants
Actions
Navigation
Tools