Hi
Does anyone know how to insert data into QuickFile from a PHP file? The only thing thats all over the API documentation is XML which is useless as I can’t do anything with it.
Any ideas?
Hi
Does anyone know how to insert data into QuickFile from a PHP file? The only thing thats all over the API documentation is XML which is useless as I can’t do anything with it.
Any ideas?
Hi
What are you stuggling with? Do you have sample code?
XML is the only supported format at the moment. There are several users on these forums who have managed to work with it.
Hi
How can I send data to QF via XML? Can’t I do it in a PHP file? Whats the best way to do it?
You can do in a PHP file, like this:
// Account Details
$AccountNumber = "61xxxxxxx";
$AppID = "xxxxxxxxxxxxxxxxxxxxxxx";
$APIKey = "xxxxxxxxxxxxxx";
$Submission = "0000001";
$MD5 = md5($AccountNumber.$APIKey.$Submission);
$xml = '<Client_Get xmlns="http://www.QuickFile.co.uk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.QuickFile.co.uk http://www.quickfile.co.uk/WebServices/API/Schemas/invoices/Client_Get.xsd">
<Header>
<MessageType>Request</MessageType>
<SubmissionNumber>'.$Submission.'</SubmissionNumber>
<Authentication>
<AccNumber>'.$AccountNumber.'</AccNumber>
<MD5Value>'.$MD5.'</MD5Value>
<ApplicationID>'.$AppID.'</ApplicationID>
</Authentication>
</Header>
<Body>
<ClientID>1</ClientID>
</Body>
</Client_Get>';
// ClientID being the QuickFile assigned ID, not an account reference
// Send data via cURL
$ch = curl_init('http://quickfile.co.uk/WebServices/API/invoices.ashx');
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
$result = curl_exec($ch);
// Close Connection
curl_close($ch);
// $result now contains the values sent back
echo $result;
You could then use the PHP simplexml library to convert the result to an object:
$object = simplexml_load_string($result);
Note: This hasn’t been tested
Ah cool, many thanks!
No problem. Obviously, that’s just one example of the Client_Get function, but have a play about with it.
I found the sandbox really useful (under Account Settings > 3rd Party Integration > API), as this shows exactly what should be going out, and what comes back. Good for debugging too
Yeah, I was going to have a play around with that.
For the submission number, what is best to do? Set it equal to a variable and auto increment the variable each time as each number has to be unique?
If I’m honest, I use a unique ID function:
$Submission = uniqid();
Seems to work
Ah, thats a good idea. Cheers!
This topic was automatically closed after 7 days. New replies are no longer allowed.