How to delete message logs in twilio trial account? - twilio-php

I am using twilio trial account for sending message and it generate SMS logs.
I want to remove all SMS logs from my trial account of twilio.
please help me.

You can use the PHP helper library to redact the body of a message, or delete the entire message resource:
$client = new Services_Twilio('AC123', '123');
$message = $client->account->messages->get("MM123");
$message->redact(); // Erases 'Body' field contents
$message->delete(); // Deletes entire message record
More info on deleting message can be found in our docs.
Hope that helps.

Related

Graph API for Outlook message restore

I had taken backup of my mail box using below rest API
GET https://graph.microsoft.com/v1.0/me/messages
But from My side this email msg deleted and i want to restore it again .
How i can do it using Rest API.
I tried with
POST https://graph.microsoft.com/v1.0/me/messages
and body with message.
but the message added as a draft not actual message.
Please help.
That is correct, when you create an email it will always save as draft unless it has been sent.
Try find the returned message id from the message creation POST, then issue a secondary POST to send it:
POST https://graph.microsoft.com/v1.0/me/messages/{id}/send
Ref: message: send

How to re-send a failed SMS with Zenvia in Rails?

I'm using Rails with Zenvia API to send Text Messages to my users.
But if a message fails to send, how could I send the same message without creating a new message ID? Is there a method to it?
Today when I try to send again the same message, it returns "Message with same ID already sent".
Turns out Zenvia API does not have a way to resend messages with same ID. At least not within 24 hours.
The solution I found was to create a token that would serve as a "fake" ID and passed it to the API. If the message for any reason fails to send, I create a new token and send it again.

Twilio error, resource not found when looking up SMS by SID

I'm trying to integrate twilio into my rails app. I want to be able to tell if there are any error messages using a response returned from the 'get' method
Twilio's example has this
#notification = #client.account.notifications.get("NO5a7a84730f529f0a76b3e30c01315d1a")
that was on this page https://www.twilio.com/docs/api/rest/notification
Here is how I'm calling it in rails console
client = Twilio::REST::Client.new(ENV['twilio_account_sid'], ENV['twilio_auth_token'])
n = client.account.notifications.get("SMb6e3a5d4649e485ea9fa818ba84ec721")
n.message_text
And I get this error
Twilio::REST::RequestError: The requested resource /2010-04-01/Accounts/[my account]/Notifications/SMb6e3a5d4649e485ea9fa818ba84ec721.json was not found
That sid is a valid sid, and I confirmed it by looking in my logs.
So why can't I look up the message with this method?
Thanks
Twilio developer evangelist here.
I think the problem is that you are not looking up a notification in your example. The SID you are using is "SMb6e3a5d4649e485ea9fa818ba84ec721" which is for an SMS message (indicated by the "SM" at the front).
As you can see in the example from the docs, notification SIDs start with "NO".
You should be able to get hold of the message you are after using client.account.messages.get('SMb6e3a5d4649e485ea9fa818ba84ec721').
You can also find all the notifications to your account by calling client.account.notifications.list.
Hope this helps, let me know if you have any other questions.

SMS parameters through twilio

I'm new to twilio and have the following situation. I want to send an SMS to someone for an appointment confirmation. They'll text back CONFIRM or CANCEL etc to the message.
Is there any way to pass an internal database id in the SMS to them and get it back in their response so i know what they're confirming or canceling? I'd rather it not be shown to the end user receiving the text.
Thanks!
Twilio evangelist here.
Unfortunately there isn't any way to transparently include metadata in an SMS and have that metadata returned to you when they reply, but there ways to address your scenario.
If you are sending the user a text message you already have their phone number and you can use that as a unique ID. When the user replies to your message, Twilio will as part of our HTTP request to your application, pass you the users phone number. You can use that number to locate them in your database and mark them as confirming or canceling.
Hope that helps.

retrieve the smsstatus after sending sms Twilio api

i m using Twilio sms api to send message form my Asp.Net application
var delivery = twilioRestClient.SendSmsMessage("+123456", mobilenumber,
string.Format("Your New Password is: {0}", genpass));
the variable delivery contains object of twiliosendsms which also contain sms status currently the status is 'queued' when the message was sent i want to know how to check if the status is changed to Sending,sent,failed,received
Twilio evangelist here.
You can use the StatusCallback to have Twilio tell you when your message was sent.
Hope that helps.

Resources