Posting a web content silently via notes agent

Please help! Is there anyway to post a web content via the notes agent to a url without interfacing with the UI, That means silently posting a web content via notes agent.

Thanks

Subject: Posting a web content silently via notes agent.

Certainly sounds possible… but a little bit of detail will go a long way.

What are you trying to do exactly?

  • More details the better.

What is the client type you intend for this solution?

  • Web Browser? Lotus Notes Client? Mobile Device Browser? All?

-Chris

Subject: RE: Posting a web content silently via notes agent.

I am trying to interface with a marchant processing API that will allow a web post. We expect our user to fill out a form on the web and submit it. We want it to go to a notes agent where we will create an html page and post it to the specified url. They will then reply back to us.

Subject: RE: Posting a web content silently via notes agent.

Wow - ok, you can do this several different ways - depending on your desired result. We’ll do this the REALLY simple way that gives you the most options.

Let’s talk about the how you’ll submit the document to the merchant processing API first, and then we’ll discuss the hiding of it…

Create a simple form:

This, even as a local HTML file, will submit the dummyform to the database agent (see the form’s processing agent). Using Request_Content as a CGI variable in the Agent, you can grab the value of “blah” that the user submits and do whatever logic you need to. Here’s some quick code that I have in my agents to do just this:

Function getContentParam (Byval content As String, Byval paramName As String, Byval debug As Boolean) As String

On Error Goto HandleThis



Dim strTemp As String, intPos As Integer



paramName = Lcase (paramName) & "="

intPos = Instr (Lcase (content), paramName)

If (intPos = 0) Then Exit Function

strTemp = Mid (content, intPos+Len(paramName))

If (Instr (strTemp, "&") > 0) Then strTemp = Strleft (strTemp, "&")

strTemp = unescape (strTemp)



If (debug) Then Msgbox paramName & ": " & strTemp



getContentParam = strTemp

done:

Exit Function

HandleThis:

Msgbox "getContentParam: " & Error & " Error#: " & Err & " at line number#: " & Erl

Resume done

End Function

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Set db = s.CurrentDatabase



Dim doc As NotesDocument, siteInfo As NotesDocument

Set doc = s.DocumentContext

	

Dim debug As Boolean, errorpage As String

debug = 1



Dim REQUEST_CONTENT As String

REQUEST_CONTENT = doc.REQUEST_CONTENT (0)

If (Len (REQUEST_CONTENT) = 0) Then REQUEST_CONTENT = doc.QUERY_STRING (0)



dim blahval as String



blahval = getContentParam (REQUEST_CONTENT, "blah", debug)



Print |[http://www.dominoguru.com/index.html?Open&val=| + blahval + |]|

End Sub

Now, this will give you an idea of how you can interact directly with an agent, pass it values via a simple HTML form post (hell, I use a lot of Cold Fusion to write to Domino databases with this very approach). Now let’s talk about doing it behind the scenes:

Note the target attribute in the form element - that’s telling the form to use the iframe. You can dynamically switch this via JavaScript, but I’m being lazy tonight and you shouldn’t really need to change the target dynamically.

Ok, now - in your Agent - create whatever URL you want to post directly to the API. Now, I don’t know this particular API, but you SHOULD be able to submit to THEIR processing agent via a POST/GET. Simply modify your agent to report something back to the users based on the result that you get back from the merchant site - JavaScript would do well here, dynamically changing either the current page or using a more dynamic approach like this:

document.getElementById(“formcontainerdiv”).innerHTML = resultmarkup;

Where resultmarkup is defined as a result of the result you get from the merchant.

Hopefully this helps - if not, email me @ ctoohey@dominoguru.com.

-Chris

Subject: RE: Posting a web content silently via notes agent.

What Chris is suggesting is certainly useful, but it is done from the user’s browser. If you want to do it from an agent, completely silent and away from the user, you should take a look at Julian’s URLFetcher script library at: nsftools.com - The May 2007 Blog

/Peter

Subject: RE: Posting a web content silently via notes agent.

Peter –

First - awesome suggestion, didn’t honestly think to use URLFetcher in this case…

Just a few things though: Doesn’t JR’s solution require certain connection allowances at the server level? IE., your server would need to have access to the web via port 80/whatever. Just something to consider, as my inner-Admin sorta pauses whenever I have a server with THAT much exposure to the outside world. URLFetcher (for this example/applied usage scenario) has DominoServer communicate directly with OutsideServer. Unless I had complete control over both servers - and maybe not even then unless we’re talking LAN/WAN here - you could run into some big-time security issues. Mind you, I could totally be off here!

The iframe-based solution (could even supe it up and use AJAX if you really wanted to) only requires that the user client have http access to the server serving up the HTML, the server hosting the Domino Agent (could be the same one), and the “merchant” server. It’s a matter of preference, intended usage/requirements, and what the current architecture will allow for really.

-Chris

Subject: RE: Posting a web content silently via notes agent.

Thanx Chris! :slight_smile:

Security is extremely important, and getting more important by the minute, but I can’t seriously see a server w/o web access to the internet. In this case, it is secure, unless you use the information retrieved from the internet in a harmful way. We are talking about a background agent here, not allowing anybody in to the server room and onto the console of the server. I have to assume that there is some sort of quality control at work here.

What the agent would do in this case is submit information to a web page over the internet, and receive back a text string containing the returned HTML. As long as you don’t download arbitrary executable files and start executing them on the server, what harm could it do? With all the web services and interoperability going on today, it’s not possible to isolate a server w/o harming the business that server is supposed to be supporting.

The fact of the matter is also that we don’t know anything about F Odiase’s environment or security concerns. All we know is that they need to be able to do a silent HTTP POST, and I believe that this is the best way to do it.

/Peter