PHP code example of emileperron / fastspring-php

1. Go to this page and download the library: Download emileperron/fastspring-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

emileperron / fastspring-php example snippets




use Emileperron\FastSpring\FastSpring;
use Emileperron\FastSpring\Entity\Order;
use Emileperron\FastSpring\Entity\Product;
use Emileperron\FastSpring\Entity\Subscription;

// First, initialize the library with your API credentials
FastSpring::initialize('your-fastspring-api-username', 'your-fastspring-api-password');

// Find all
$orders = Order::findAll();

// Find single by ID/path
$product = Product::find('mytestproduct');

// Find all with filters
$orders = Order::findBy(['products' => 'mytestproduct']);

// Find by IDs
$subscriptions = Subscription::find(['2XzdAW3_SMSl1I18ccj26A', '9zGdAW3_AM1L6I18cqj21Y']);

// Deleting
$product->delete();

// Working with entities
foreach ($subscriptions as $subscription) {
	echo $subscription['state'] . "\n";
}

// Making manual requests to the API
$response = FastSpring::get('orders');
$response = FastSpring::post('products', [
	'products' => [
		[
			'product' => 'mytestproduct',
			'sku' => 'my-updated-sku'
		]
	]
]);
$response = FastSpring::delete('orders', ['8UzdwW3_qM6lgI18Pca52y']);

composer