christopherhill
7/11/2013 - 8:31 PM

Marketo Web Proxy

Marketo Web Proxy

<?php

  	$staging = "http://marketostaging.domain.com/index.php/leadCapture/save";
	$production = "http://marketoproduction.domain.com/index.php/leadCapture/save";

	$url = '';

	if (isset($_GET["s"])) {
		
		$stagingFlag = $_GET["s"];
		
		if ($stagingFlag == "true") {
			$url = $staging;
		} else {
			$url = $production;
		}

	} else {

		$url = $production;

	}
	
	if (isset($_GET["Email"])) {
		
		$options = array(
	    	'http' => array(
	        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
	        'method'  => 'POST',
	        'content' => http_build_query($_GET),
	    	),
		);

		// todo: must try to preserve referer, which is currently correct due to the simultaneous firing of the createLead API   call.

		$context  = stream_context_create($options);
		$result = file_get_contents($url, false, $context);

		// var_dump($result);

	} else {
	
		header("HTTP/1.0 403 Forbidden");
	
	}

?>