Module: Rmobio::Ads::MKhoj

Defined in:
lib/rmobio/ads/m_khoj.rb

Constant Summary collapse

@@default_ip =
"59.181.113.59"

Instance Method Summary collapse

Instance Method Details

#get_ad(keywords, ad_client, request, kw_type = "broad") ⇒ Object



28
29
30
# File 'lib/rmobio/ads/m_khoj.rb', line 28

def get_ad(keywords,ad_client,request,kw_type="broad")
  getAd(keywords,ad_client,ip=request.remote_ip,request.request_uri,request.user_agent,request.env["HTTP_USERID"],kw_type="broad")
end

#getAd(keywords, adClient, ip = request.remote_ip, url = request.request_uri, useragent = request.user_agent, userid = request.env["HTTP_USERID"], kw_type = "broad") ⇒ Object



32
33
34
# File 'lib/rmobio/ads/m_khoj.rb', line 32

def getAd(keywords,adClient,ip=request.remote_ip,url=request.request_uri,useragent=request.user_agent,userid=request.env["HTTP_USERID"],kw_type="broad")
  getAdByPage(adClient,ip,url,useragent) # keywords have no effect in mKhoj 
end

#getAdByPage(adClient, ip = request.remote_ip, url = request.request_uri, useragent = request.user_agent) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rmobio/ads/m_khoj.rb', line 36

def getAdByPage(adClient,ip=request.remote_ip,url=request.request_uri,useragent=request.user_agent)
  # mKhoj just detects your URL, so you don't really need an adClient variable for this particular network!
  # carrier="59.181.113.59" # only works with India carriers!!
  # TODO: find out how to give MKHOJ a userid for tracking!
  useragent="nokia6030" if useragent.size>30  # doesn't handle browser access well, tell it we're a Nokia 6030
  ip=@@default_ip if ip.index("70.90") # doesn't handle our accessing IP well
  adUrl = "http://www.mkhoj.com/view/Traffic/ShowAd.aspx?siteId=" + adClient +"&handset="+URI.escape(useragent)+"&carrier="+ip   
  # e.g. adUrl="http://www.mkhoj.com/view/Traffic/ShowAd.aspx?siteId=330ed28f-0de9-4c4f-b0a8-1f2118358c80&handset=nokia6030/&carrier=59.181.113.59"
  $log.info "Calling: " + adUrl
  begin
    @ad = open(adUrl).read   
    $log.info "Returned ad: " + @ad
  rescue
  end 
  @ad
end