constfrom=VONAGE_BRAND_NAMEconstto=TO_NUMBERconsttext='A text message sent using the Vonage SMS API'vonage.message.sendSms(from,to,text,(err,responseData)=>{if(err){console.log(err);}else{if(responseData.messages[0]['status']==="0"){console.log("Message sent successfully.");}else{console.log(`Message failed with error: ${responseData.messages[0]['error-text']}`);}}})
Add the following to the main method of the SendMessage class:
TextMessagemessage=newTextMessage(VONAGE_BRAND_NAME,TO_NUMBER,"A text message sent using the Vonage SMS API");SmsSubmissionResponseresponse=client.getSmsClient().submitMessage(message);if(response.getMessages().get(0).getStatus()==MessageStatus.OK){System.out.println("Message sent successfully.");}else{System.out.println("Message failed with error: "+response.getMessages().get(0).getErrorText());}
varresponse=VonageClient.SmsClient.SendAnSms(newVonage.Messaging.SendSmsRequest(){To=TO_NUMBER,From=VONAGE_BRAND_NAME,Text="A text message sent using the Vonage SMS API"});
$response=$client->sms()->send(new\Vonage\SMS\Message\SMS(TO_NUMBER,BRAND_NAME,'A text message sent using the Nexmo SMS API'));$message=$response->current();if($message->getStatus()==0){echo"The message was sent successfully\n";}else{echo"The message failed with status: ".$message->getStatus()."\n";}
responseData=sms.send_message({"from":VONAGE_BRAND_NAME,"to":TO_NUMBER,"text":"A text message sent using the Nexmo SMS API",})ifresponseData["messages"][0]["status"]=="0":print("Message sent successfully.")else:print(f"Message failed with error: {responseData['messages'][0]['error-text']}")
vonage.messages.send(newWhatsAppText("This is a WhatsApp Message text message sent using the Messages API",TO_NUMBER,WHATSAPP_NUMBER),(err,data)=>{if(err){console.error(err);}else{console.log(data.message_uuid);}});
client=Vonage::Client.new(application_id: VONAGE_APPLICATION_ID,private_key: File.read(VONAGE_APPLICATION_PRIVATE_KEY_PATH))message=Vonage::Messaging::Message.whatsapp(type: 'text',message: "This is a WhatsApp Message text message sent using the Messages API")client.messaging.send(from: VONAGE_WHATSAPP_NUMBER,to: TO_NUMBER,**message)