Tengo un form que envia un mail, bueno pues hasta ahi vamos bien, pero necesito que luego o mientras envía cae al send.php, me corra newsApi.php con los mismo valores...les dejo mis codes...
Código PHP:
<?php
$to = '[email protected]' . ', '; // note the comma
$to .= "$email";
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$title = @$_POST["title"];
$text = @$_POST["text"];
$memo = $_POST['memo'];
$thank="thanks.html";
$message = "
<p><strong>Nombre:</strong> " .$name."</p>
<p><strong>E-mail:</strong> " .$email."</p>
<p><strong>Telefono:</strong> ".$telefono."</p>
<p><strong>Producto:</strong> ".$title."</p>
<p><strong>Informacion del producto:</strong> <br> ".$text."</p>
<strong>Mensaje:</strong> " .$memo."";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: " .$email;
if (mail($to,$email,$message,$headers))
Header ("Location: $thank");
?>
Código PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$API_KEY_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$API_KEY_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$FORM_ID = 'xxxxxxxxx';
/*
Example 1: Inserting or updating one address into your mailing list
*/
$telefono = $_POST['telefono'];
$nombre = $_POST['nombre'];
$iemail = $_POST['email'];
$url = "https://secure.directmailmac.com/api/v1/forms/$FORM_ID/addresses/" . urlencode( $iemail );
$body = array(
"create_if_necessary" => true,
"address" => array(
"Nombre:" => $nombre,
"Telefono:" => $telefono,
"custom" => array( "1" => "[Nombre]", "2" => "[Telefono]" )
)
);
print_r( execute_api_request( "PUT", $url, $body ) );
function execute_api_request( $method, $url, $body = null )
{
global $API_KEY_ID, $API_KEY_SECRET;
$decoded_response = NULL;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method );
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt( $ch, CURLOPT_USERPWD, "$API_KEY_ID:$API_KEY_SECRET" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
if ( $body ) {
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $body ) );
}
try {
$response = curl_exec( $ch );
if ( $response === false ) {
error_log( sprintf( "Request failed %s %s: %s (%d)\n", $method, $url, curl_error( $ch ), curl_errno( $ch ) ) );
}
else if ( $response ) {
$decoded_response = json_decode( $response, true );
if ( $decoded_response === null ) {
error_log( "Unable to decode JSON $response" );
}
}
}
catch ( Exception $e ) {
error_log( "Caught exception while requesting $method $url: " . $e->getMessage() );
}
curl_close( $ch );
return $decoded_response;
}
?>