Inneractive, HTTP library, LoadURL, Ads

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I am trying to use the Inneractive Mobile Ad service. They have an M2M interface that is web-based. They say they have better payout rates. I thought I would give them a try.

If I use the B4A HTTP library –

B4X:
  t = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd"
  req.InitializeGet(t)

  hc.SetHttpParameter("aid", "MyAppID")
  hc.SetHttpParameter("v", "Sm2m-1.5.3")
  hc.SetHttpParameter("po", "559")

  hc.Execute(req, 1)

I get a response from Inneractive, but the response is always "No Ad".

If I use a WebView and LoadURL -

B4X:
  t = "http://m2m1.inner-active.com/simpleM2MclientRequestHtmlAd?aid=MyAppID" & _
    "&v=Sm2m-1.5.3&po=559"
  wvAd.LoadUrl(t)

I also get a response, and the response shows what looks like a valid banner ad.

This leads me to believe the HTTP Get is not sending what I think it should be sending. The LoadURL gives me an ad, but I need to parse the response for a "sequence" parameter to use when I make the next ad request.

Q's:
1. Is there a way to see the actual string that the HTTP Get sends out. It looks like it's not sending the right thing, but I can see no way to view what it is actually sending.

2. Is there a way to look at the returned string using LoadURL? It displays in the WebView, but I can see no way to get access to the returned string so that I can parse it for the "sequence" parameter.

3. Anybody use Inneractive? They claim to be good and they have quite a bit of web discussion activity.


And Happy New Year!


Thanks,
Barry.
 
Last edited:

pluton

Active Member
Licensed User
Longtime User
I'm little drunk from new year :D but why don't you use something with this:

B4X:
Dim aid, v, po, t as String
aid = "MyAppID"
v = "Sm2m-1.5.3"
po = "559"

' Now just call for example

t = "http://m2m1.inner-active.com/simpleM2MclientRequestHtmlAd?aid=" &aid& "&v="&v& "&po=" &po
  wvAd.LoadUrl(t)

I wrote this from my mind. I'm too drunk to start the B4A today ;)
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Thanks.
We still have a few more hours to go. Then I'll be joining you in the festivities.

There are many ways to build the URL string.

I guess the real point of my question concerned getting a valid response from Inneractive and also being able to parse the response to capture the "sequence" value they return to help prevent repeated ads.

If I use the HTTP library, for some reason I get the response "No Ad" from the Inneractive add server. If I use the WebView LoadURL function, passing what I think is the same information, I get back a valid looking ad, but I am not able to parse the response for the "sequence" value.

Any help in these 2 areas is appreciated.

Barry.
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Canalrun, May I ask an off-topic question? How can you got AppID? I tried to add new app but there's no AppID for me :(
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Pluton is correct. You should pass the parameters as GET parameters. Not part of the Http headers as you are doing in the first post.


Thanks. I've also tried the following. Which results in an error at "execute" because HTTP does not like the "&" character. I then used StringUtilts EncodeURL on "t". HTTP likes this, but Inneractive responds "No Ad".

I believe my "t" and Pluton's "t" will result in the same string. Originally I was trying to add Get parameters. Can you expand a little on how to do that?


B4X:
t = "http://m2m1.inner-active.com/simpleM2MclientRequestHtmlAd?aid=MyAppID&v=Sm2m-1.5.3&po=559"

  req.InitializeGet(t)

  hc.Execute(req, 1)


Susu:

Good question. After registering at Inneractive, I also have not explicitly received an app ID. From what I have read on the Internet, the app ID is a text string with underscores in it – so I'm assuming it is just what they call "App Name" on their dashboard. Mine is something like "App_AppName_Android". I used this. Using the WebView LoadURL, I got back a response that looked like a valid ad. On the dashboard my request count has not incremented. I have tried to contact Inneractive with these questions, but received no response yet. It's the week before new year – maybe they are on vacation.

Another burning question for me is: "How to request a specific size add?"

From what I've seen, you can't. I am hoping to receive an official answer from Inneractive.

If you find any answers I would love to hear them.


Thanks,
Barry.
 
Last edited:
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
That's strange, I have an app with several "&" in a Http call and it works.

Thanks. That's good to hear. I will try this again.

Android reported "invalid character at position 63". Position 63 was the "&" character. After retyping and retrying a few times, getting the same error, I just assumed HTTP did not like ampersands.

Barry.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
This is one of the many lines with "&" in one of my apps:

B4X:
req.InitializeGet("http://chart.finance.yahoo.com/t?s=F&width=310&height=200")

hc.Execute(req, 1)

It works just fine.
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
Thanks. That's good to hear. I will try this again.

Android reported "invalid character at position 63". Position 63 was the "&" character. After retyping and retrying a few times, getting the same error, I just assumed HTTP did not like ampersands.

Barry.

Maybe is problem that you break the line with underscore character
TIP
Try without breaking the "t" line

Sent from my LG-P500
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Maybe is problem that you break the line with underscore character
TIP
Try without breaking the "t" line

Sent from my LG-P500

Thanks. I will give it another try. Maybe I had that or some other error embedded.

Barry.


Added Later:

I gave your suggestion a try – and it worked.
The error I was getting referred to character position 63 which was an &, but the real error must've been something else – maybe the line continuation.

I have posted the test program I am using below.
As Susu pointed out. The string for AppID that I'm using is just my guess. I have not gotten an official AppID from Inneractive. (The one shown is not the actual one I'm using)

The response I got is again "No Ad", but at least it is not a fatal error, and it is totally understandable since my AppID is likely wrong.
Since I'm am using HTTPclient I am able to parse the result.

Now I have a new question… Oh no!

The docs for B4A say that one should do a Response.Release in the success subroutine as is done in the error subroutine.

If I use the GetAsynchronously, Response.Release is never called. (I copied this stuff pretty much directly from the docs)
Is Response.Release called internally during invocation of StreamFinish?

Thanks much,
Barry.


B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

    Dim hc As HttpClient

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   
   Dim pnlAd As Panel
   Dim wvAd As WebView

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_Create(FirstTime As Boolean)
  Dim s, t, r As String
  Dim su As StringUtils
  Dim pMap As Map
  
  Activity.LoadLayout("IAT.bal")
   
  pnlAd.Width = 320dip
  pnlAd.Height = 350dip
  pnlAd.Left = (100%x - pnlAd.Width) / 2
  pnlAd.Top = (100%y - pnlAd.Height) / 3
   
  wvAd.Width = pnlAd.Width
  wvAd.Height = pnlAd.Height
  wvAd.Left = 0
  wvAd.Top = 0
  
  If FirstTime Then
      hc.Initialize("hc")
  End If

  Dim req As HttpRequest

  t = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd?aid=MyAPPID&v=Sm2m-1.5.3&po=559"
  req.InitializeGet(t)
  hc.Execute(req, 1)
End Sub

Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
  Response.GetAsynchronously("IAResp", File.OpenOutput(File.DirInternalCache, "IAResp.txt", False), True, TaskId)
End Sub

Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
  Log("Error connecting: " & Reason & " " & StatusCode)
   
  If (Response <> Null) Then
      Log(Response.GetString("UTF8"))
      Response.Release
  End If
End Sub 

Sub IAResp_StreamFinish (Success As Boolean, TaskId As Int)
  Dim s As String
  
  If (Success = False) Then
    Msgbox(LastException.Message, "Error")
    Return
  End If

  s = File.ReadString(File.DirInternalCache, "IAResp.txt")
End Sub
 
Last edited:
Upvote 0

Orly

New Member
Licensed User
Longtime User
Hey Barry,

My name is Orly and I am Developers Account Manager at inneractive.
I would like to assist you with the issue that you are experiencing, so you will be able to complete your integration easily.
Please send me an email to orly@inner-active.com with request and respond that you recive from your server.

Looking forward to hear from you.
Orly
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
Thanks. I will give it another try. Maybe I had that or some other error embedded.

Barry.


Added Later:

I gave your suggestion a try – and it worked.
The error I was getting referred to character position 63 which was an &, but the real error must've been something else – maybe the line continuation.

The error was your line continuation _
 
Upvote 0
Top