PHP code example of silverstripe / intercom

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

    

silverstripe / intercom example snippets


\SilverStripe\Intercom\IntercomScriptTags::config()->enabled = false;

use SilverStripe\Core\Injector\Injector;
use SilverStripe\Intercom\Intercom;

$intercom = Injector::inst()->get(Intercom::class);
$intercom->trackEvent('test-event', array(
    'something' => 'a value',
    'other-one' => 'moar data',
));

use SilverStripe\Core\Injector\Injector;
use SilverStripe\Intercom\Intercom;
use SilverStripe\Security\Member;

$member = Member::get()->byID(34);
$intercom = Injector::inst()->get(Intercom::class);
$intercom->trackEvent('test-event', array(
    'something' => 'a value',
    'other-one' => 'moar data',
), $member);

$client->trackEvent("test-event", [
    "something" => "a value",
    "other-one" => "moar data",
], Member::get()->byID(34));

use SilverStripe\Security\Member;

/**
 * Factory for generating a DataList of all platform users
 */
class AllUserListFactory
{
    public function create($class, $params)
    {
        return Member::get()->filter(['Some' => 'Value']);
    }
}

$form
    ->addIntercomUserFieldMapping([
		'FullName' => 'name',
		'EmailAddress' => 'email'
	])
	->addIntercomCompanyFieldMapping([
		'CompanyName' => 'name'
	])
	->sendToIntercom();

$form->addIntercomUserFieldMapping([
    "FavouriteColour" => "\$favourite_color"
]);

$form
    ->addIntercomNoteMapping([
		'SoftwareVersion' => 'The user is running version:'
	])
	->setIntercomNoteHeader('More information about this user');