PHP code example of connect / connect-client

1. Go to this page and download the library: Download connect/connect-client 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/ */

    

connect / connect-client example snippets


use Connect\Connect;

Connect::initialize('your-project-id', 'your-push-api-key');

$purchase = [
	'customer' => [
	   'firstName' => 'Tom',
	   'lastName' => 'Smith'
	],
	'product' => '12 red roses',
	'purchasePrice' => 34.95
];

Connect::push('purchases', $purchase);

$batch = [
	'purchases' => [
		[
            'customer' => [
                'firstName' => 'Tom',
                'lastName' => 'Smith'
			],
			'product' => '12 red roses',
			'purchasePrice' => 34.95
		],
		[
            'customer' => [
                'firstName' => 'Fred',
				'lastName' => 'Jones'
			],
			'product' => '12 pink roses',
			'purchasePrice' => 38.95
		]
	]
];

Connect::push($batch);

$masterKey = 'YOUR_MASTER_KEY';
$keyDefinition = [
    'filters' => [
        'type' => 'cycling'
    ],
    'canQuery' => True,
    'canPush' => True
];
	
$filteredKey = Connect::generateFilteredKey($keyDefinition, $masterKey);
print $filteredKey;