PHP code example of ossbrownie / esputnik
1. Go to this page and download the library: Download ossbrownie/esputnik 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/ */
ossbrownie / esputnik example snippets
$eSputnik = new ESputnik(
new HTTPClient(
new CurlClient(),
new Config([
'login' => 'tester',
'password' => 'passwd'
])
)
);
{
$version = $eSputnik->version();
}
{
$contact = new Contact();
$contact
->setFirstName('FName')
->setLastName('LName')
->setContactKey('[email protected] ');
$channelList = new ChannelList();
$channelList->add(new EmailChannel([
'value' => '[email protected] '
]));
$fieldList = new FieldList();
$fieldList
->add(new Field([
'id' => 12345,
'value' => 'CustomValue1',
]))
->add(new Field([
'id' => 12346,
'value' => 'CustomValue2',
]));
$contact
->setFieldList($fieldList);
$contact
->setChannelList($channelList);
$subscribe = new Subscribe();
$subscribe
->setFormType('test_type')
->getGroups()->add(new Group([
'name' => 'Test group'
]));
$response = $eSputnik->contactSubscribe($contact, $subscribe);
}
{
$addressbooks = $eSputnik->addressbooks();
}
{
$groups = $eSputnik->groups();
}
{
$params = new ParamList();
$params
->add(new Parameter([
'name' => 'EmailAddress',
'value' => '[email protected] ',
]));
$eSputnik->event(new Event([
'eventTypeKey' => 'test-test',
'keyValue' => 'test-' . time(),
'params' => $params
]))
}
bash
$> composer.phar install
$> ./vendor/bin/phpunit --colors=always --bootstrap ./tests/bootstrap.php ./tests