Client API

Mobile Applications API - no SDK required!

below the (ruby) code to be used by clients and their mobile applications in order to trigger advertising campaigns


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@post_ws = "/api/v1/thunder"


def do_post
          req = Net::HTTP::Post.new(@post_ws, initheader = {'Content-Type' =>'application/json',"Accept" => "application/json"})
          req.basic_auth @user, @pass
          req.body = @payload
          response = Net::HTTP.new(@host, @port).start {|http| http.request(req) }
          puts "Response #{response.code} #{response.message}: "
          p "#{response.body}"
end

def get_dob
  t = Date.today
  t = t - rand(5400..12000)
  p ">>>>>: " + t.to_s
  t
end


######
#INFO - MINIMUM POSTING RULES
######
#'app' has be filled minimum with these keys:
#appid == the id of the app
#appsec == app secret
#device has to carry at least ONE key
#keys has to carry at least ONE appkey
######
#optional:
#mode = live|test # if ommitted, then live is assumed. spedicfy 'test' if desired

p "------------------------------------------------------------------------A1 - Location: Northvale, NJ 07647, USA"
#######EX1 - simple post
lat = 41.0008 
lng = -73.9506
devicedetails = { 'screenw' => 111+rand(0..150), 'screenh'=>222+rand(200..400) ,'model'=>"iphone#{rand(1..6)}"}
hscore = rand(1000..15000)
#p "hscore: #{hscore}"
@payload ={
    "device" => devicedetails,
    "keys" => {'level'=>rand(0..10), 'highscore'=>hscore, 'windpseed'=>3},
    "event" => {'lat'=>lat, 'lng'=>lng, 'dob'=>get_dob},
    "app" => {'appid'=> '1002' , 'appsec'=>'d455467196b84a71bfa118efa6f22695', 'appgid'=>999, 'mode'=>'test','channel'=>'email','email'=>"tomabroad@gmail.com"}
}.to_json
#do_post
p "------------------------------------------------------------------------A2 END"