The Dapper REST web service for extracting
content uses a given Dapp to extract content from one type of page on a given website (e.g., "search result" pages on MSN Search).
A Dapp is called by accessing the REST web service. For the Dapp, MSN Search Results, the simplest way to call it is as follows.
http://www.dapper.net/RunDapp?v=1&dappName=MSNSearchResults
You'll notice that the dappName argument in the URL above is case sensitive and is a "URL safe" version of the Dapp title (dappName = "MSNSearchResults" whereas the Dapp's title is "MSN Search Results"). You can find the dappName (also refered to as a "Dapp identifier") on the Dapp's "How to Use" page. The "How to Use" page for the MSN Search Results Dapp is located at:
http://www.dapper.net/dapps/MSNSearchResults
The REST call returns XML (described in a separate document) for the "default URL" of
the Dapp. For instance, in the MSN Search Results example, the Dapp was built out of several "sample pages". The first sample page was for a
search for "oranges." As a result, when you query the MSN Search Results Dapp directly, without specifying a specific search, the returned XML will contain the search results for "oranges." If you wish to specify that the Dapp should return results for a different search, you can call it with an "applyToUrl" containing the encoded URL of the page that contains the search in question. So, if the URL that contains the search results for "Dapper" is:
http://search.msn.com/results.aspx?q=Dapper
You would encode the URL above (in PHP use rawurlencode and in Java use URLEncoder.encode) and then supply it as an argument to RunDapp as follows:
http://www.dapper.net/RunDapp?dappName=MSNSearchResults&v=1&applyToUrl=http%3A%2F%2Fsearch.msn.com%2Fresults.aspx%3Fq%3DDapper
That, as you would expect, causes the Dapp to extract content from the
URL supplied.
If, when constructed, the Dapp had "input variables" specified, you can pass the values of the input variables to the Dapp as GET arguments. You would pass them as follows, in the case of MSN Search Results, if you wanted to search for "Funny Times":
http://www.dapper.net/RunDapp?v=1&dappName=MSNSearchResults&variableArg_0=Funny%20Times
If there is more than one variable argument, simply increase the index
in the GET argument (variableArg_1, etc.). There are some Dapps where
the name of the GET argument is different - it looks like
variableArg_BLAH, where BLAH corresponds to an internal name for the
variable. This will be covered in another document.
In addition to these arguments, if a Dapp requires a username and
password (e.g., it operates on a site that is behind a login form), they
are passed like this:
http://www.dapper.net/RunDapp?v=1&dappName=DAPP_NAME&username=USERNAME&password=PASSWORD&encryptionAlg=1
If USERNAME and PASSWORD are clear-text, then encryptionAlg=1 should be
omitted. To encrypt usernames and passwords, just POST them to
http://www.dapper.net/encrypt-credentials.jsp
Which will return a JSON object containing the encrypted values.