VBScript:
If request("connection_token") <> "" Then
'Get connection_token
connection_token = request("connection_token")
'Site Settings
site_subdomain = "lightningclass"
site_public_key = "MyPublicKey"
site_private_key = "MyPrivateKey"
'API Access Domain
site_domain = site_subdomain + ".api.oneall.com"
'Connection Resource
resource_uri = "https://" + site_domain + "/connections/"+connection_token+".xml"
site_authentication = site_public_key + ":" + site_private_key
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setTimeouts 30,500,1000,1000
xmlhttp.Open "GET", resource_uri
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.Send site_authentication
theResponse = xmlhttp.responseText
Set xmlhttp = nothing
End If
Java example:
// Your Site Settings
String site_subdomain = 'REPLACE WITH YOUR SITE SUBDOMAIN';
String site_public_key = 'REPLACE WITH YOUR SITE PUBLIC KEY';
String site_private_key = 'REPLACE WITH YOUR SITE PRIVATE KEY';
// API Access Domain
String site_domain = site_subdomain + '.api.oneall.com';
// Connection Resource
resource_uri = 'https://' + site_domain + '/connections.json';
// Result Container
String result_json = "";
try
{
// Forge authentication string username:password
String site_authentication = site_public_key + ":" + site_private_key;
String encoded_site_authentication = new String(new Base64().encode(site_authentication.getBytes())).replaceAll("[\n\r]", "");
// Setup connection
URL url = new URL (resource_uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Connect using basic auth
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Basic " + encoded_site_authentication);
connection.setDoOutput(true);
connection.setReadTimeout(10000);
connection.connect();
connection.getInputStream();
StringBuilder sb = new StringBuilder();
String line = null;
// Read result
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((line = rd.readLine()) != null) {
sb.append(line);
}
result = sb.toString();
}
catch (Exception e)
{
e.printStackTrace();
}
// Done
System.out.println (result);
If request("connection_token") <> "" Then
'Get connection_token
connection_token = request("connection_token")
'Site Settings
site_subdomain = "lightningclass"
site_public_key = "MyPublicKey"
site_private_key = "MyPrivateKey"
'API Access Domain
site_domain = site_subdomain & ".api.oneall.com"
'Connection Resource
resource_uri = "https://" & site_domain & "/connections/" & connection_token & ".xml"
site_authentication = site_public_key & ":" & site_private_key
encoded_site_authentication = Base64Encode(site_authentication)
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setTimeouts 30,500,1000,1000
xmlhttp.Open "GET", resource_uri
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Authorization", "Basic " & encoded_site_authentication
xmlhttp.Send site_authentication
theResponse = xmlhttp.responseText
Set xmlhttp = nothing
End If
Function Base64Encode(inData)
'ripped from:
'http://www.pstruh.cz/tips/detpg_Base64Encode.htm
'rfc1521
'2001 Antonin Foller, PSTRUH Software, http://pstruh.cz
Const Base64 = _
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim sOut, I
'For each group of 3 bytes
For I = 1 To Len(inData) Step 3
Dim nGroup, pOut
'Create one long from this 3 bytes.
nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
&H100 * MyASC(Mid(inData, I + 1, 1)) + _
MyASC(Mid(inData, I + 2, 1))
'Oct splits the long To 8 groups with 3 bits
nGroup = Oct(nGroup)
'Add leading zeros
nGroup = String(8 - Len(nGroup), "0") & nGroup
'Convert To base64
pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)
'Add the part To OutPut string
sOut = sOut + pOut
Next
Select Case Len(inData) Mod 3
Case 1: '8 bit final
sOut = Left(sOut, Len(sOut) - 2) + "=="
Case 2: '16 bit final
sOut = Left(sOut, Len(sOut) - 1) + "="
End Select
Base64Encode = sOut
End Function
Function MyASC(OneChar)
If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
End Function
Dim connection_token, site_domain, site_subdomain, site_public_key, site_private_key, resource_uri
Dim result_json, site_authentication, encoded_site_authentication
Dim http: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
If request("connection_token") <> "" Then
'Get connection_token
connection_token = request("connection_token")
'Site Settings
site_subdomain = "lightningclass"
site_public_key = "c680df0b-767g-40d8-8951-32ab89b1be7e"
site_private_key = "d0b63363-bb98-4ab6-b3b8-40d4b11b5981"
'API Access Domain
site_domain = site_subdomain + ".api.oneall.com"
'Connection Resource
resource_uri = "https://" + site_domain + "/connections/"+connection_token+".xml"
site_authentication = site_public_key + ":" + site_private_key
'Always specify username/password here, for fail safety
http.open "GET", resource_uri, False, site_public_key, site_private_key
http.setRequestHeader "Authorization", "Basic " & Base64Encode(site_authentication)
http.send
Response.ContentType = "text/xml"
http.responseXML.save Response
End If
<?xml version="1.0" encoding="UTF-8"?>-<response>
-<request>
<date>Sat, 11 Jan 2014 00:30:35 +0100</date>
<resource>/connections/9f671859-7440-4926-ab7f-5e8a206c8db4.xml</resource>
-<status>
<flag>error</flag>
<code>401</code>
<info>Authentication credentials are missing or incorrect: http://docs.oneall.com/api/basic/authentication/</info>
</status>
</request>
</response>
Dim connection_token, site_subdomain, site_public_key, site_private_key, xmlDoc
Dim http: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
'Get connection_token
connection_token = request("connection_token")
'Site Settings
site_subdomain = "lightningclass"
site_public_key = "public key"
site_private_key = "private key"
'API Access Domain
site_domain = site_subdomain + ".api.oneall.com"
'Connection Resource
resource_uri = "https://" + site_domain + "/connections/"+connection_token+".xml"
site_authentication = site_public_key + ":" + site_private_key
'Always specify username/password here, for fail safety
http.open "GET",resource_uri,False,site_public_key,site_private_key
http.setRequestHeader "Authorization", _
"Basic " & Base64Encode(site_authentication)
http.send
Response.ContentType = "text/xml"
http.responseXML.save Response
set xmlDoc=http.responseXML
set http = nothing
Now I'm faced with the next problem. The XML file displays on the screen. I need to be able to save it so I can test some fields and save some fields. The file that is being saved has lost all formatting and labels. Have been scouring the web for answers. I'm guessing for our purposes, this should be a separate question.