Browse Source

on try catch les erreurs sms du retour, pour eviter une fatal error

issue3_lister_sms
tofulm 5 months ago
parent
commit
276132d693
  1. 2
      classes/smsfactor/sendSMSclass.php
  2. 61
      sms_fonctions.php

2
classes/smsfactor/sendSMSclass.php

@ -67,4 +67,4 @@ class SendSMSclass
}
?>
?>

61
sms_fonctions.php

@ -52,37 +52,44 @@ function smsfactor($message,$destinataire,$arg) {
}
$retour = $SENDSMS->SendSMS($username,$password,$sender,$message,$destinataire);
$reponse = new SimpleXMLElement($retour);
if ( $reponse->message == "OK" ) {
if (count($destinataire)) {
$cost = $reponse->cost;
$sent = $reponse->sent;
$nbr_sms = 0;
if ($sent != 0) {
$nbr_sms = $cost / $sent;
}
$type_sms = '';
if (array_key_exists('type_sms', $arg)) {
$type_sms = $arg['type_sms'];
}
foreach ($destinataire as $tel) {
$set = array(
'telephone' => md5($tel),
'date' => date("Y-m-d H:i:s"),
'message' => $message,
'nbr_sms' => $nbr_sms,
'type_sms' => $type_sms
);
sql_insertq('spip_sms_logs',$set);
libxml_use_internal_errors(true);
try{
$reponse = new SimpleXMLElement($retour);
if ( $reponse->message == "OK" ) {
if (count($destinataire)) {
$cost = $reponse->cost;
$sent = $reponse->sent;
$nbr_sms = 0;
if ($sent != 0) {
$nbr_sms = $cost / $sent;
}
$type_sms = '';
if (array_key_exists('type_sms', $arg)) {
$type_sms = $arg['type_sms'];
}
foreach ($destinataire as $tel) {
$set = array(
'telephone' => md5($tel),
'date' => date("Y-m-d H:i:s"),
'message' => $message,
'nbr_sms' => $nbr_sms,
'type_sms' => $type_sms
);
sql_insertq('spip_sms_logs',$set);
}
}
return true;
} else {
spip_log('le message '.$message.' pour ' . implode(',' , $destinataire) . 'est en erreur' , 'sms_error');
return false;
}
return true;
} else {
} catch (Exception $e){
spip_log('le message '.$message.' pour ' . implode(',' , $destinataire) . 'est en erreur' , 'sms_error');
return false;
spip_log($e , 'sms_error');
}
}
/**

Loading…
Cancel
Save