1. Go to this page and download the library: Download talon-one/talon-one-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/ */
talon-one / talon-one-client example snippets
Configure Host, API key, & API key prefix for integration authentication
$config = \TalonOne\Client\Configuration::getDefaultConfiguration()
->setHost('https://yourbaseurl.talon.one')
->setApiKeyPrefix('Authorization', 'ApiKey-v1')
->setApiKey('Authorization', 'dbc644d33aa74d582bd9479c59e16f970fe13bf34a208c39d6c7fa7586968468');
// Initiating an integration api instance with the config
$apiInstance = new \TalonOne\Client\Api\IntegrationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default when `null` is passed.
null, // new YouClientImplementation(),
$config
);
$customer_session_id = 'customer_session_id_example'; // string | The unique identifier for this session
$customer_session = new \TalonOne\Client\Model\NewCustomerSessionV2([
'profileId' => 'example_prof_id',
'couponCodes' => [
'Cool-Summer!'
],
'cartItems' => [
new \TalonOne\Client\Model\CartItem([
'name' => 'Hawaiian Pizza',
'sku' => 'piz-hw-001',
'quantity' => 1,
'price' => 5.85
])
]
]);
$body = new \TalonOne\Client\Model\IntegrationRequest([
'customerSession' => $customer_session,
// Optional list of requested information to be present on the response.
// See lib/Model/IntegrationRequest.php#getResponseContentAllowableValues for full list
// 'responseContent' => [
// \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_CUSTOMER_SESSION,
// \TalonOne\Client\Model\IntegrationRequest::RESPONSE_CONTENT_COUPONS
// ]
]);
try {
// Create/Update a customer session using `updateCustomerSessionV2` function
$integration_state = $apiInstance->updateCustomerSessionV2($customer_session_id, $body);
print_r($integration_state);
// Parsing the returned effects list, please consult https://developers.talon.one/Integration-API/handling-effects-v2 for the full list of effects and their corresponding properties
foreach ($integration_state->getEffects() as $effect) {
if ("addLoyaltyPoints" == $effect->getEffectType()) {
// Initiating right props instance according to the effect type
$props = new \TalonOne\Client\Model\AddLoyaltyPointsEffectProps((array) $effect->getProps());
// Access the specific effect's properties
echo $props->getName(), ':: ', $props->getRecipientIntegrationId(), ' just earned ', $props->getValue(), ' points', PHP_EOL;
}
if ("acceptCoupon" == $effect->getEffectType()) {
// Initiating right props instance according to the effect type
$props = new \TalonOne\Client\Model\AcceptCouponEffectProps((array) $effect->getProps());
// work with AcceptCouponEffectProps' properties
// ...
}
}
} catch (Exception $e) {
echo 'Exception when calling IntegrationApi->updateCustomerSessionV2: ', $e->getMessage(), PHP_EOL;
}
Configure Host, API key, & API key prefix for management authentication
$config = \TalonOne\Client\Configuration::getDefaultConfiguration()
->setHost('https://yourbaseurl.talon.one')
->setApiKeyPrefix('Authorization', 'ManagementKey-v1')
->setApiKey('Authorization', '2f0dce055da01ae595005d7d79154bae7448d319d5fc7c5b2951fadd6ba1ea07');
// Initiating a management api instance with the config
$apiInstance = new \TalonOne\Client\Api\ManagementApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default when `null` is passed.
null, // new YouClientImplementation(),
$config
);
try {
$application_id = 7; // int | desired application identifier
// Calling `getApplication` function
$application = $apiInstance->getApplication($application_id);
print_r($application);
} catch (Exception $e) {
echo 'Exception when calling ManagementApi->getApplication: ', $e->getMessage(), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.