customerio / customerio-php Goto Github PK
View Code? Open in Web Editor NEWExamples for using PHP to access the Customer.io API
Examples for using PHP to access the Customer.io API
Hi
This is not properly working insert data but not insert proper data.
$session = curl_init();
$customer_id = '22'; // You'll want to set this dynamically to the unique id of the user associated with the event
$customerio_url = 'https://track.customer.io/api/v1/customers/'.$customer_id.'/events';
$site_id = '';
$api_key = '';
$name = "purchased";
$attributes = array('email' => '[email protected]', 'color' => 'pink');
$data = array('name' => $name, 'data' => $attributes);
// Sends a purchased event
curl_setopt($session, CURLOPT_URL, $customerio_url);
curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_VERBOSE, 1);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($session, CURLOPT_POSTFIELDS,http_build_query($data));
curl_setopt($session,CURLOPT_USERPWD,$site_id . ":" . $api_key);
// if(ereg("^(https)",$request)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false);
$response = curl_exec($session);
echo $response;
curl_close($session);
http://customer.io/docs/api/php.html does not properly show how to add attributes to an event.
It does not make clear that the custom attributes must go in a 'data' field. I figured that out by looking at the other pages, but a working PHP example would have been nice.
Came here to submit a pull request and noticed you had already addressed it in the repo.
Did not work:
if(ereg("^(https)",$request)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false);
Works:
if(ereg("^(https)",$customerio_url)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.