Skip to content

Instantly share code, notes, and snippets.

@jsvini
Created December 7, 2016 19:47
Show Gist options
  • Save jsvini/758d88899ff56e38a13823be2c3d8f88 to your computer and use it in GitHub Desktop.
Save jsvini/758d88899ff56e38a13823be2c3d8f88 to your computer and use it in GitHub Desktop.
Registrar um lead no RDStation com CURL
<?php
$data = array(
'token_rdstation' => 'SEU_TOKEN_PRIVADO', // seu token
'nome' => @$_POST['nome'],
'email' => @$_POST['email'],
'identificador' => 'teste-identificador' // identificador
);
// adiciona a origem do lead (é necessário incluir o script abaixo no site se quiser identificar a origem do lead)
// <script type="text/javascript" async src="https://d335luupugsy2.cloudfront.net/js/loader-scripts/be36fbd7-5587-4c13-95c5-957a3cc16498-loader.js" ></script>
if(!empty($_COOKIE["rdtrk"])){ $data["client_id"] = json_decode($_COOKIE["rdtrk"])->{'id'}; };
if(!empty($_COOKIE["__trf_src"])) {$data["traffic_source"] = $_COOKIE["__trf_src"]; };
$data_string = json_encode($data);
$ch = curl_init('https://www.rdstation.com.br/api/1.3/conversions');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment