Solved

why Klaviyo has 2 separate PHP repository

  • 7 December 2022
  • 1 reply
  • 112 views

Badge +1

Major Problem 1

 

Why there are 2 separate Klaviyo repositories?

  1. https://github.com/klaviyo/klaviyo-api-php
  2. https://github.com/klaviyo/klaviyo-php-sdk

I am trying to create/update a Profile through api call,

  • creation works well with `createProfile()` function of `klaviyo-api-php`, but there are no functions to update the profile.
  • To update the profile, I have to use `updateProfile()` from `klaviyo-php-sdk`

why there is not a single repository with all necessary functions ?

 

Major Problem 2

 

profile creation expects following params,

'type' => 'profile',
'attributes' => [
'email' => $user->email,
'phone_number' => $user->phone ?? '',
'external_id' => $user->id,
'first_name' => $user->first_name,
'last_name' => $user->last_name,
// custom properties
‘properties’ => [ … ]
]
 
Note: the custom properties are expected inside the `attributes`, but the above same paramaters do not work for profile updation, The custom properties have to have outside the `properties` array element, as follow.
 
[
type' => 'profile',
'attributes' => [
'email' => $user->email,
'phone_number' => $user->phone ?? '',
'external_id' => $user->id,
'first_name' => $user->first_name,
'last_name' => $user->last_name,
// custom properties
‘custom_property’ => ‘value’
...
]
icon

Best answer by Brian Turcotte 8 December 2022, 21:20

View original

1 reply

Userlevel 7
Badge +36

Hi @parthjani7 and welcome to the Community!

 

This is a great question! As far as your first issue, we have two SDK repositories because the first one you linked corresponds to our new V3 APIs, and the second you linked corresponds to our legacy APIs, so the calls and syntax differ in certain ways.

 

To that end, you won’t be able to use the new V3 API endpoints with the old SDK, you will have to install the new SDK. Once you do that, you will be able to both create and update profiles using calls to the V3 Profiles endpoint:

As far as the second issue - may I ask if you could clarify the question a bit? More specifically, are you asking why the syntax is different for create/update profile in terms of custom properties? If so, it’s because there were slight syntactical changes during the update to V3 APIs, and since you alluded to using the legacy APIs for ‘update’ and the new APIs for ‘create’, the syntax will be different. 

 

I hope this helps to clarify, and thanks for using the Community!

- Brian

Reply