LearningToProgram
asked on
Getting data from a website into Access database
Hi, I've got an Access 2007 database.
I want to update some of the tables in this database with data that is online. The online company has given me the Authorization key and some PHP examples of how to use their API.
(http://api.realstatistics.com/help/api-code-examples/basics/)
However, I don't know PHP, and just know VBA with Access. From what I have been able to determine (correct me if I'm wrong), I will have to use XMLHTTP to send and receive the data.
I've attached an example of a sample of code their website gives me using PHP:
And I've attached my attempt, which doesn't work (it gets me a response that looks like it's sending their entire webpage back to me.)
What I need help with is exactly what command to send using XMLHTTP.
thanks!
I want to update some of the tables in this database with data that is online. The online company has given me the Authorization key and some PHP examples of how to use their API.
(http://api.realstatistics.com/help/api-code-examples/basics/)
However, I don't know PHP, and just know VBA with Access. From what I have been able to determine (correct me if I'm wrong), I will have to use XMLHTTP to send and receive the data.
I've attached an example of a sample of code their website gives me using PHP:
And I've attached my attempt, which doesn't work (it gets me a response that looks like it's sending their entire webpage back to me.)
What I need help with is exactly what command to send using XMLHTTP.
thanks!
<?php
// Get the companies
$companies = $stat->get_companies();
// Check to see if it was successful
if ( $stat->success ) {
foreach ( $companies as $company ) {
// Do stuff...
}
} else {
// Show response
echo $stat->message;
}
?>
Dim oHttpRequest As Object
Dim key As String
Dim url As String
Dim postdata As String
Dim Response As String
Public Function realstats(Optional Email As String) As String
Set oHttpRequest = CreateObject("Microsoft.XMLHTTP")
url = "http://api.realstatistics.com/"
postdata = "auth_key = xxxxxxxxxxxxxxxxx & method = get_companies()"
oHttpRequest.Open "POST", url, False
oHttpRequest.Send (postdata)
If (oHttpRequest.Status >= 200 And oHttpRequest.Status < 300) Then
Response = oHttpRequest.responseText
End If
Dialog.Box Response
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER