Quixly
Digital Delivery and File Sharing. The Easy Way.
Public API
The full Quixly Public API has not yet been released. Below you will find the portion of the full API that is available.
What is the API used for?
The Public API is used to interface with Quixly from your own website or application. Currently the only API method available is the "orders" method. You would use this to tell Quixly when an order has been placed on your system. You would send Quixly all the necessary info about the transaction, and Quixly will take it from there. Quixly will then create an order record for the transaction and email your customer a link to download the appropriate file.
Below we have an example of how to do this in PHP. However, you are not limited to PHP and can use any language you want.
"orders" Method
- URL https://YOUR_ACCOUNT_NAME.quixly.com/api/orders/?api_key=YOUR_API_KEY¶m=value¶m=value...
- Request Method POST
- Return Format JSON
- Parameters
- sku: Required SKU/ID of the file to be downloaded. This is a value assigned to each file you upload into Quixly, and can be found inside the Quixly application. Numbers and Letters only. Example: 52
- email: Required Email address of the customer who made the purchase. This is the email that will be used to deliver the files.
- total_price: Required Total price of the transaction. Numbers only. Example: 89.99
- origin: Required This is a description of where the order came from. For example, if your web store was named "Cool Store", you might want the origin to be "cool store". If you have multiple web stores ("Cool Store" and "Dog Store") tied to a single Quixly account, you can differentiate which orders came from where by using this origin parameter. Cannot be "paypal" or "google", your order will fail if you use those.
- transaction_id: Optional If you have your own internal transaction ID system you can send that ID over to Quixly as well to make it easier to find orders from within the Quixly application.
- fullname: Optional Name of the customer who made the purchase. This can be used to personalize the emails sent with Quixly.
When you make a request to the API, it will return a status of 200 is everything completes successfully. If there are any errors, it will return a status of 400. Below are examples of the JSON returned to you along with the status code.
- 200 { count: TOTAL_COUNT_HERE } - The "count" is the total number of items we processed (ex: 3).
- 400 { error: "ERROR_MESSAGE_HERE" }
PHP cURL Example:
Here is an example using the cURL library in PHP to send Order information to Quixly server side. You would want to run this cURL request in your system whenever a new Order or Transaction is made (ie. someone buys something).
This example requires you have PHP 5.2 or greater and PHP cURL installed on your server.
Be sure to replace anything in blue with your actual Order/Transaction values, and your Quixly account information.
$params = array('api_key' => 'YOUR_API_KEY', 'sku' => '52', 'email' => 'customer@email.com', 'total_price' => '89.99', 'origin' => 'My Store', 'transaction_id' => '12345', 'fullname' => 'Customer Name');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://YOUR_ACCOUNT_NAME.quixly.com/api/orders/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
//If you get "error communicating with Quixly server", add this option.
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$json = json_decode($response);
if (@$json->count > 0){ // check to see if any records were affected
echo "success";
} else {
if ($json){
echo @$json->error;
} else {
echo "error communicating with Quixly server";
}
}