klaviyo / klaviyo-php-sdk

PHP SDK for Klaviyo API
https://developers.klaviyo.com
MIT License
17 stars 9 forks source link

TrackIdentify POST requests require missing token #9

Closed joelvh closed 1 year ago

joelvh commented 1 year ago

The TrackIdentify API client doesn't set the API key in the request, so identifyPost fails. When I explicitly add it to the data I pass to the method it works.

I looked at the source and the other API clients set the API key, but this one doesn't.

Additionally, it would be very helpful to show a code example of each method call because the docblocks are not accurate. For example, identifyPost is annotated with # $data | string -- but it takes an array. A string doesn't even work.

jon-batscha commented 1 year ago

Hey! Good catch on the docs being off! Will update them shortly.

In the meantime, the identifyPost endpoint actually takes in an associative array. That array should be structured exactly as described in the corresponding section of our API Docs.

As you’ll see, $data should contain a token field; hopefully that resolves your issue.



That said, you are not the first to bring this up, and I am in total agreement that this is a suboptimal design. With that in mind, I am happy to share that we are pretty far along in developing our new and improved API (and corresponding SDK), which resolves this issue among its many other improvements. This upcoming API is currently in closed Alpha, but if you are interested in learning more, feel free to connect with our team here: developers@klaviyo.com. You can also sign up for our developer newsletter in the footer of our developer site: developers.klaviyo.com.

And do please reach out with any additional questions or suggestions; your feedback is critical to our mission of releasing ever-better developer tools.

Cheers! Jon

joelvh commented 1 year ago

thanks @jon-batscha. Regarding the API client, will it start setting the token internally for the Track/Identify methods like it does in the other endpoints? We added the token to the array we pass in to make it work, but we don't need to do that with the others.

jon-batscha commented 1 year ago

To clarify: for our current API/SDKs, you will need to continue setting the token within the data array, but only for the endpoints under TrackIdentify. The reason for this is that those endpoints are unique, in that they use a public token (as opposed to a private api_key).

Our upcoming API (and corresponding SDKs), still in closed alpha, will resolve this quirk.

Hopefully that answered your question; if not, please let me know, and I'd be happy to elaborate further.