tengo 2 opciones viables para mi usando script en php o java sim embargo estoy un poco perdido por que no he logrado conectar el script al formulario
en el link se encuentran los parametros del script les agradeceria mucho su ayuda si alguien puede brindarmela. gracias de antemano
[URL="http://gateway160.com/doc/sendmessage"]http://gateway160.com/doc/sendmessage[/URL]
el script que no logro hacer funcionar con el formulario es el siguiente :
Código PHP:
<!--?php
function post_request($url, $data, $optional_headers = null)
{
// data needs to be in the form of foo=bar&bar=foo
$data = http_build_query($data);
$params = array(
'http' =--> array(
'method' => 'POST',
'content' => $data,
// you need to specify the content length header
'header' => "Content-type: application/x-www-form-urlencoded\r\n"
. 'Content-Length: ' . strlen($data) . "\r\n"
));
if ($optional_headers !== null) {
// append optional_headers if it is not null
$params['http']['header'] .= $optional_headers;
}
$ctx = stream_context_create($params);
$fp = fopen($url, 'r', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
fclose($fp);
return $response;
}
$post_data = array(
'accountName' => 'MyAccount',
'key' => 'xxxxffxx-xxxx-xxxx-xxxx-xxxxd2d3xxxx',
'phoneNumber' => '9998887777',
'message' => 'Hello World', //please perform URLEncode on this field
'countryCode' => 'US'
);
try
{
$result = post_request('http://api.gateway160.com/client/sendmessage/', $post_data);
if($result == "1")
{
echo "Sent Successfully";
}
else
{
//error (check the response code from the chart above)
echo "Error";
}
}
catch (Exception $e)
{
echo "Exception: " . $e->getMessage();
}
?>