|
Post by jlbachiochi on Sept 14, 2013 8:28:19 GMT -5
I have a number of IPs that are sending posts to my IP. I would like to use RB to grab the data and append it to a txt file. Any ideas?
|
|
|
Post by meerkat on Sept 14, 2013 9:44:58 GMT -5
Not exactly sure if I understand what exactly you are after. But if people on the web are looking at you web site and you want to know information about them you can simply run a RB program to log the data.
For example you can place this in each of your web pages you want to watch for hits.
<iframe src="http://www.yourdomain.com:8008/seaside/go/runbasicpersonal?app=webhits&RBP" frameborder="no" height="1" width="1"> </iframe>
The &RBP, or &something, is whatever you place in each web page to identify it
You need to write a RB program called webhits. Mine looks like this:
' --------------------------------- ' log user hits ' --------------------------------- yourDir$ = "../webhits_project/" ' need your directory projectDir$ = "webhits_project" ' need your project directory webhitsFile$ = DefaultDir$ + "\projects\" + projectDir$ + "\webhits.txt" s$ = " || " la = len(UserAddress$) ua$ = UserAddress$ + left$(" ",15 - la) 'print date$("yyyy-mm-dd");s$;time$();s$;ua$;s$;word$(UrlKeys$,2,"&");s$;Platform$;s$;UserInfo$
if UserAddress$ <> "192.168.1.1" then ' stops you from looking at yourself open webhitsFile$ for append as #f print #f, date$("yyyy-mm-dd");s$;time$();s$;ua$;s$;word$(UrlKeys$,2,"&");s$;Platform$;s$;UserInfo$ close #f end if ' thats all folks end
Then write a RB program to analyse the logged data.
Not sure this is what you want. Hope it helps.
|
|
|
Post by jlbachiochi on Sept 14, 2013 10:06:54 GMT -5
The data is coming from devices around the web that use HTTP POST to send the formatted data. I suspect I might use...
HTTP Request object methods
The HTTP Request object method is always referenced by the global handle name #request.
#request GET$(name$) - Return the string value for name$. This comes from the last HTTP form POST. #request ISNULL() - Returns zero (or false)
... but not sure how to use these. Am I on the right track?
|
|
|
Post by meerkat on Sept 14, 2013 12:39:46 GMT -5
I think you got it..
Try this and see if it works for you:
dim selCompType$(10) dim selCompTypeDescr$(10)
for i = 1 to 10 selCompType$(i) = "Type";str$(i) selCompTypeDescr$(i)= "Description ";str$(i) next i [loop] html "<table><tr>" html "<TD align=right>CompType</TD><TD>" html "<SELECT name='compType'>" for i = 1 to 10 if compType$ = selCompType$(i) then sel$ = "selected" else sel$ = "" html "<option value='";selCompType$(i);"' ";sel$;">";selCompTypeDescr$(i);"</option>" next i html "</select>" html "</TD></TR><TR>" html "<TD align=right>Name</TD><TD>" html "<input type='text' name='name' id='name' value='";name$;"' size=40/>" html "</TD></TR>" html "<TR bgcolor=wheat><TD colspan=2 ALIGN=CENTER>" button #acd, "Submit", [doIt] #acd setkey(thiscomprowid$) button #ex, "Exit", [doExit]
html "</TD></TR></TABLE>" wait [doIt] cls '-------------- compType ------------------- compType$ = #request get$("compType")
'-------------- name ------------------- name$ = #request get$("name") print "You Chose" print "Company Type:";compType$;" Name: ";name$ goto [loop] [doExit] cls print "Good bye!" end
hope this helps
|
|
|
Post by jlbachiochi on Sept 16, 2013 12:25:38 GMT -5
The problem is I want this to be automatic, no submit button, let me explain further with a little code...
'-------------- text ------------------- html "<input type='hidden' name='text' id='id' value='";text$;"' size=40/>" html "<br>" text$=#request get$("text")
[File] open "/public\Poll.txt" for append as #writeIt print #writeIt, UserAddress$;",(text$=";text$;")" close #writeIt 'print UserAddress$;",(text$=";text$;")" end
Assuming a 'post' comes to this url, I want to log the variable text$ to a file.
To simulate a post coming in I am using this code...
url$="192.168.1.69:8008"
[loop] button #acd, "Post text$", [doIt] button #ex, "Exit", [doExit] wait
[doIt] cls x=x+1 name$=chr$(34)+"text"+chr$(34) value$=chr$(34)+"Test "+str$(x)+chr$(34) packet$=chr$(123)+name$+":"+value$+chr$(125) #acd setkey(text$) print text$ on error goto [httpGetError] message$=httppost$(url$, packet$)
[results] print "httppost$ to:";url$ print "packet:";packet$ print "return:";message$ goto [loop]
[doExit] end
The url used here goes to the RB server which is serving the first program. I assume the post is in the JSON format. I hope this is clear.
--jeff
|
|