Message-ID: <365724140.15827.1614958334491.JavaMail.confluence@wiki> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_15826_165191470.1614958334491" ------=_Part_15826_165191470.1614958334491 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
It is always possible for your request to return an error. If an error o= ccurs, e.g. if your API username/password is incorrect, our wrapper will th= row a PHP exception. If you're not familiar with handling exceptions in PHP= , it basically means you need to put the wrapper function calls in a try-ca= tch block.
try { =09$sent =3D $tmClient->sendSMS('My message', '447000000000', 'Sender'); } catch (Exception $ex) { =09$errors =3D $tmClient->getLastErrors(); }=20
You must decide how to handle errors according to the logic of your part= icular application. For example, if you're building a web interface to send= text messages, and a send fails, you may wish to show a visual alert to th= e user.
Note that more than one error can be reported at once. Therefore althoug= h a single PHP exception (the first of the errors) is thrown, the complete = set of errors encountered is available in an array of key-value pairs. The = key of each pair is the error code and the value is a detailed description = of the error.
foreach($errors as $errorcode =3D> $errormsg) =09echo "Error encountered with code $errorcode: $errormsg\n";=20
You must know!
=20 =20Our example code is an illustra= tion of how you might integrate with our systems and is not certified for p= roduction environments. You are responsible for testing and QA.