2017 © Pedro Peláez
 

library connect-client

PHP Connect SDK for interacting with the Connect API

image

connect/connect-client

PHP Connect SDK for interacting with the Connect API

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Connect PHP SDK

Join the chat at https://gitter.im/getconnect/connect-php, (*1)

Build Status Latest Stable Version, (*2)

The Connect PHP SDK allows you to push events to Connect from PHP., (*3)

If you don’t already have a Connect account, sign up here - it’s free!, (*4)

Installation

The easiest way to install the Connect SDK is to use Composer., (*5)

Add connect/connect-client as a dependency and run composer update., (*6)

"require": {
    …
    "connect/connect-client" : "0.*"
    …
}

Usage

Initializing a client

use Connect\Connect;

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

Pushing events

Once you have initialized Connect, you can push events easily:, (*7)

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

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

You can also push events in batches:, (*8)

$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);

Generating filtered keys

To generate a filtered key, (*9)

$masterKey = 'YOUR_MASTER_KEY';
$keyDefinition = [
    'filters' => [
        'type' => 'cycling'
    ],
    'canQuery' => True,
    'canPush' => True
];

$filteredKey = Connect::generateFilteredKey($keyDefinition, $masterKey);
print $filteredKey;

Exception handling

When pushing events, exceptions could be thrown, so you should either ignore or handle those exceptions gracefully., (*10)

Currently, the following exception could be thrown when pushing events:, (*11)

  • InvalidEventException - the event being pushed is invalid (e.g. invalid event properties)

License

The SDK is released under the MIT license., (*12)

Contributing

We love open source and welcome pull requests and issues from the community!, (*13)

The Versions

24/08 2015

dev-master

9999999-dev https://getconnect.io

PHP Connect SDK for interacting with the Connect API

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics events connect

24/08 2015

0.2.0

0.2.0.0 https://getconnect.io

PHP Connect SDK for interacting with the Connect API

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics events connect

22/07 2015

0.1.1

0.1.1.0 https://getconnect.io

PHP Connect SDK for interacting with the Connect API

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics events connect

22/07 2015

0.1.0

0.1.0.0 https://getconnect.io

PHP Connect SDK for interacting with the Connect API

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics events connect