Lenguaje "PHP"
Enviar mensajes – REST API – JSON
[php]
"https://api.labsmobile.com/json/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"message":"Text of the SMS message", "tpoa":"Sender","recipient":[{"msisdn":"12015550123"},{"msisdn":"447400123456"},{"msisdn":"5212221234567"}]}',
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
[/php]Consulta de créditos – REST API – JSON
[php]
"https://api.labsmobile.com/json/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$auth_basic,
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
[/php]Enviar mensajes – HTTP/GET
[php] Details:' . "[/php]
" . $result); } } ?>SMS Example
Consulta de créditos – HTTP/GET
[php] Details:' . "[/php]
" . $result); } ?>SMS Example credit query
Enviar mensajes – HTTP/POST XML
[php]
:MSISDN
handset
http://clientserver.com/motest.php
';
$sms = utf8_encode(str_replace(array(':MSISDN', ':MESSAGE'), array($_POST['msisdn'], $_POST['message']), $sms));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'XmlData='.$sms);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$result = curl_exec($ch); curl_close($ch);
$message = htmlentities('Message has been sent.
Details:' . "
" . $result);
}
}
?>
SMS Example
[/php]Consulta de créditos – HTTP/POST
[php]
Details:' . "
" . $result);
}
?>
SMS Example credit query
[/php]Recepción confirmación ACK
[php]
[/php]Enviar mensajes – WebService
[php]
getError();
if ($err) {
echo 'Constructor error
' . $err . '
';
}
$client->soap_defencoding = 'UTF-8';
$funciones = array();
$params = array();
$result = $client->call('SendSMS', array('client' => "priv001", 'username' => "acct01@demo.com", 'password' => "acct01pwd", 'xmldata' => "
34609542312
"), '', '', false, true);
if ($client->fault) {
echo '
Fault
';
print_r($result);
echo '
';
} else {
$err = $client->getError();
if ($err) {
echo '
Error
' . $err . '
';
} else {
echo '
Result
';
print_r($result);
echo '
';
}
}
echo '
Request
' . htmlspecialchars($client->request, ENT_QUOTES) . '
';
echo '
Response
' . htmlspecialchars($client->response, ENT_QUOTES) . '
';
echo '
Debug
' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
';
?>
[/php]