1. Go to this page and download the library: Download sammakescode/klaviyo-api 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/ */
sammakescode / klaviyo-api example snippets
use \SamMakesCode\KlaviyoApi\KlaviyoApi;
use \SamMakesCode\KlaviyoApi\Objects\Metric;
use \SamMakesCode\KlaviyoApi\Objects\Profile;
$client = new KlaviyoApi('your-api-key');
$client->events()->create(Event::make(
[
'properties' => [
'custom_property' => 'Why, yes!',
],
],
Metric::make('Created Account'),
Profile::make([
'email' => '[email protected]',
])
));
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use SamMakescode\KlaviyoApi\KlaviyoApi;
class KlaviyoServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(KlaviyoApi::class, function () {
return new KlaviyoApi(
env('KLAVIYO_API_KEY'),
);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.