PHP code example of bentonow / bento-php-sdk

1. Go to this page and download the library: Download bentonow/bento-php-sdk 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/ */

    

bentonow / bento-php-sdk example snippets


use bentonow\Bento\BentoAnalytics;

$bento = new BentoAnalytics([
  'authentication' => [
    'secretKey' => 'bento-secret-key',
    'publishableKey' => 'bento-publishable-key'
  ],
  'siteUuid' => 'bento-site-uuid'
]);

$bento->V1->tagSubscriber([
  'email' => '[email protected]',
  'tagName' => 'New Customer',
]);

$bento->V1->addSubscriber([
  'email' => '[email protected]',
  'fields' => [
    'firstName' => 'John',
    'lastName' => 'Doe',
  ],
]);

$bento->V1->removeSubscriber([
  'email' => '[email protected]',
]);

$bento->V1->updateFields([
  'email' => '[email protected]',
  'fields' => [
    'firstName' => 'John',
  ],
]);

$bento->V1->trackPurchase([
  'email' => '[email protected]',
  'purchaseDetails' => [
    'unique' => [
      'key' => 1234,
    ],
    'value' => [
      'amount' => 100,
      'currency' => 'USD',
    ],
  ],
]);

$bento->V1->track([
  'email' => '[email protected]',
  'type' => '$custom.event',
  'details' => [
    'fromCustomEvent' => true,
  ],
]);

$bento->V1->Batch->importSubscribers([
  'subscribers' => [
    ['email' => '[email protected]', 'age' => 25],
    ['email' => '[email protected]', 'name' => 'Jane Doe'],
  ]
]);

use bentonow\Bento\SDK\Batch\BentoEvents;

$bento->V1->Batch->importEvents([
  'events' => [
    ['email' => '[email protected]', 'type' => BentoEvents::SUBSCRIBE],
    ['email' => '[email protected]', 'type' => BentoEvents::UNSUBSCRIBE],
    [
      'email' => '[email protected]',
      'details' => [
        'customData' => 'Used internally.'
      ],
      'type' => '$custom.myEvent'
    ]
  ]
]);

$bento->V1->Commands->addTag([
  'email' => '[email protected]',
  'tagName' => 'VIP',
]);

$bento->V1->Commands->removeTag([
  'email' => '[email protected]',
  'tagName' => 'VIP',
]);

$bento->V1->Commands->addField([
  'email' => '[email protected]',
  'field' => [
    'key' => 'favoriteColor',
    'value' => 'blue',
  ],
]);

$bento->V1->Commands->removeField([
  'email' => '[email protected]',
  'fieldName' => 'favoriteColor',
]);

$bento->V1->Commands->subscribe([
  'email' => '[email protected]',
]);

$bento->V1->Commands->unsubscribe([
  'email' => '[email protected]',
]);

$bento->V1->Events->createEvent([
  'type' => '$completed_onboarding',
  'email' => '[email protected]',
]);

$bento->V1->Experimental->validateEmail([
  'email' => '[email protected]',
]);

$bento->V1->Experimental->guessGender([
  'name' => 'Alex',
]);

$bento->V1->Experimental->geolocate([
  'ip' => '127.0.0.1',
]);

$bento->V1->Experimental->checkBlacklist([
  'domain' => 'example.com',
]);

$fields = $bento->V1->Fields->getFields();

$bento->V1->Fields->createField([
  'key' => 'favoriteColor',
]);

$responses = $bento->V1->Forms->getResponses('form-id-123');

$subscriber = $bento->V1->Subscribers->getSubscribers([
  'email' => '[email protected]',
]);

$bento->V1->Subscribers->createSubscriber([
  'email' => '[email protected]',
]);

$tags = $bento->V1->Tags->getTags();

$bento->V1->Tags->createTag([
  'name' => 'Premium',
]);
bash
composer