Hi - hope someone can help. I suspect I'm making a fairly basic error.
I'm attempting to use the klaviyo-api-php library, hosted on GitHub, to add subscribers and update profiles.
I've already successfully used the php library to retrieve info on profiles i.e. using $klaviyo->Lists->getListProfiles($list_id, $fields_profile, $filter);
However I'm now really stuck when trying to subscribe a profile to list.
Error message returned is:"status":400,"code":"invalid","title":"Invalid input.","detail":"The payload provided in the request is invalid.","source":{"pointer":"/data"},"meta":{}}]}
I can't figure out how to structure the data in the request $body.
I know it needs to be an associative array and have tried various options, but everything I try fails.
Below is my $body payload. (list_id removed)
I'd be really grateful if anyone could help me structure or format it correctly. I can't see where I'm going wrong!
I'd be really grateful for any help. Many thanks
$body = array(
'list_id' => 'LIST_ID',
'profiles' => array(
array(
'email' => 'user@example.com',
'properties' => array(
'$first_name' => 'John',
'$last_name' => 'Doe',
),
),
),
);
$klaviyo->Profiles->subscribeProfiles($body);
GitHub docs:
https://github.com/klaviyo/klaviyo-api-php#user-content-subscribe-profiles
## Positional Arguments
# $body | associative array
$klaviyo->Profiles->subscribeProfiles($body);
Klaviyo API docs:
https://developers.klaviyo.com/en/v2022-10-17/reference/subscribe_profiles