function marketo_add_to_campaign($leadId, $marketo_token) { $campaignId = $_POST["cpnid"]; $request_action = "/v1/campaigns/" . $campaignId . "/trigger.json"; $rest_call = generate_call($request_action, $marketo_token); $request_data = array('input' => array('leads' => array(array("id" => $leadId)))); return make_rest_call($rest_call, $request_data); }
function get_lead_data($fields) { include_once plugin_dir_path(__FILE__) . "form-actions.php"; $field_names = $lead_data = array(); foreach ($fields as $field) { array_push($field_names, $field["field_name"]); } $marketo_token = get_marketo_token(); $request_action = "/v1/leads.json?filterType=cookie&filterValues=" . str_replace("&", "%26", $_COOKIE["_mkto_trk"]) . "&fields=" . implode(",", $field_names); $rest_call = generate_call($request_action, $marketo_token, false); $lead_data = make_rest_call($rest_call, null, "get")->result[0]; if ($lead_data) { $lead_data = get_object_vars($lead_data); } return $lead_data; }