[AccessD] Hooking into APIs of supplemental vendors

Stuart McLachlan stuart at lexacorp.com.pg
Sat Jul 6 19:48:18 CDT 2013


API = "Application Programmers Interface".  It is the set of instructions  for how to "interface" 
their developed utilities into your "application".

It may be provided as a set of documents, a set of Include files for you particular 
development environment on both. 

.................

Ah-ha!   This one is a web API/Interface using REST (Representational State Transfer).

That's a bit different.   Essentially, you are sending and receiving packets of data to/from a 
web server.  There's a good primer here: http://rest.elkstein.org/

To use it in Access, you neet to go one step further than your example below.

The "PUT ....." is the command you send to the webserver, you then need to parse out the 
response.   

To PUT the command, you need to use the component of Windows which is used for 
communications via the HTTP protocol.  (It is  COM based, rather than "classic" API, so you 
need to use Objects)

Here's a faily simple example I knocked up some time ago showing a simlar concept.  It gets 
an exchange rate from a web site.   In your case, about all you would need to do would be to 
change the URL in strParam, change everything after the question mark in strParam to the 
example shown, change the "GET" to "PUT"  in the oHTTP.Open line and change the way 
you parse the response.

Function GetExchRate(strFromCurr As String, strtoCurr As String) As Double
    Dim oHTTP As Object
    Dim lngresult As Long
    Dim strPage As String
    Dim strParam As String
    strParam = 
"http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" & _
               strFromCurr & "&ToCurrency=" & strtoCurr
    Set oHTTP = CreateObject("Msxml2.XMLHTTP")
    lngresult = oHTTP.Open("GET", strParam, False)
    lngresult = oHTTP.Send("")
    strPage = oHTTP.Responsetext
    Set oHTTP = Nothing
    lngresult = InStr(strPage, "<double xmlns=""http://www.webserviceX.NET/"">")
    GetExchRate = Val(Mid$(strPage, lngresult + 44))
End Function


 

On 6 Jul 2013 at 16:43, William Benson (VBACreations. wrote:

> Example:
> 
> http://trumpia.com/main/Developer_SMS_Gateway_API.php
> 
> This was the message I got. I went to the Get Started section and started
> reading about a whole variety of things I had no idea what I was looking at.
> So I really don't know what an API is, I guess, I thought they were code
> snippets that made things happen and that if I looked at them long enough
> they would make sense to me. Apparently not. The email I got from some guy I
> thought was going to show me how they work, included:
> 
> "...  Customers that are interested in our API are recommended to review the
> API Functions to confirm they are compatible..... 
> 
> Well I looked at them and then made no sense to me:
> 
> Example Resource Request (Adding a Contact)
> To demonstrate how our REST API works, let's take a look at how
> subscriptions, or contacts, are added to your Trumpia database. First, you
> would send the following resource request URI using the PUT method:
> 
>     PUT http://api.trumpia.com/rest/v1/{user_name}/subscription
> 
>     {
>       "list_name" : "restapi",
>       "subscriptions" : 
>       [
>         {
>           "first_name":"firstname01",
>           "last_name":"lastname01",
>           "email":"email01 at address.com",
>           "aim":"testaim",
>           "mobile":
>           {
>             "number":"1010101010",
>             "country_code":"1"
>           },
>           "voice_device" : "mobile"
>         },
>         {
>           "first_name":"firstname02",
>           "email":"email02 at address.com",
>           "landline":
>           {
>             "number":"1234567890",
>             "country_code":"1"
>           },
>           "voice_device" : "landline"
>         }
>       ]
>     }
> 
> ----
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list