Hello,
I am trying to learn Twilio API.
When I [send SMS through php][1] script.. twilio returns a response object with status = 'queued'. Now I want to get notified when the status changes to 'sent'. Is this possible with Twilio??? and if yes then could any body advise me on how to implement his.
And how to add 'StatusCallback' url
$sms = $client->account->sms_messages->create(
// the number we are sending from, must be a valid Twilio number
"000-000-0000",
// the number we are sending to - Any phone number
"0000000000",
// the sms body
"Hey Friend, Monkey Party at 6PM. Bring Bananas!"
);
You're on the right track looking to the StatusCallback. When using the Twilio PHP Library any optional parameters can be set using an array as the last argument.
<?php
$sms = $client->account->sms_messages->create(
"1235551234",
"1235554321",
"Hey Friend, Monkey Party at 6PM. Bring Bananas!",
array('StatusCallback' => 'http://example.com/sms/status.php')
);
When the message is sent (or if it fails) the data will be passed to the StatusCallback url.
Related
I am currently trying to run a custom function in Zoho Desk that is triggered on ticket creation, targeting tickets created by our support#zoho... email address, that converts incoming emails into tickets.
More specifically, when an email contains a JSON attachment, I would like the custom function to be able to read the attachment and pull the JSON data from the attachment.
Is this possible? Has anyone had any success?
Below is the code I have, thought I was on the right track but run into the error below
//TicketID is set as an Argument for the custom function
ORGID = "********";
getthread = zoho.desk.getRelatedRecords(ORGID,"threads","tickets",TicketID);
threadid = getthread.getJSON("data").getJSON("id");
getthreadcontent = zoho.desk.getRelatedRecordById(ORGID,"threads",threadid,"tickets",TicketID);//.getJSON("content");
info getthreadcontent.getJSON("attachments").getJSON("name"); //Prints the Attachment Name (Works)
info getthreadcontent;//.getJSON("attachments").getJSON("href");//Prints the Attachment URL (Works)
response = invokeUrl
[
url: getthreadcontent.getJSON("attachments").getJSON("href")
type: GET
];
The above code returns this error:
{"errorCode":"UNAUTHORIZED","message":"You are not authenticated to perform this operation."}
Any help or pointers would be greatly appreciated :)
It looks like you might need to add your Zoho Auth Token to the URL, first, and then make the invoke_url() call.
This is the Scenario:
In the same Azure tenant, I used one account (user_1_address) to send emails to the other account (user_2_address) using outlook (o365).
I sent 3 emails, one where user_2_address is BCCed, one CCed, and one when it's the TO recipient.
I'm using Microsoft graph API to get a list of emails received by user_2_address in a specific time range, using this query:
https://graph.microsoft.com/v1.0/users/{<user_2_id>}/messages?$filter=
receivedDateTime ge <some date> and receivedDateTime lt <some other date>
and isDraft eq false
and sender/emailAddress/address ne '<user_2_address>'
I'm getting all the three emails user_2_address had received from user_1_address. But in the email user_2 was BCCed the bccRecipients list is empty, when it should contain user_2_address :(
I have seen this question about sending an email from Gmail and BCC an outlook user:
Microsoft graph API: empty BCC field
In that case, also the bccRecipients list was empty, but it was resolved by saying the BCC is removed when sending the emails from an external source (Gmail in that case). When for me it's not an external source - both users are using outlook in the same tenant.
So my questions are:
Is it the desired behaviour, or is it a bug?
Now, let's say I'm using the query above where I get all emails where the sender is not the user_2_address and it's not a draft. Can I assume that every email I get where user_2_address is not in the ccRecipients and toRecipients lists - that email was BCCed to user_2_address?
Thanks!
The bcc field in a Message is an envelope (P1) recipient only so you should always expect that it will be blank (no matter the context inside a tenant really make no difference). Like the other post referenced if it wasn't blank it would break the RFC and the purpose of a BCC, the only exception is the sent item (which is just a copy of the sent message)
No there are many scenarios that would break that particular logic eg forwarded email is one the comes to mind. You could certainly refine you result set that way, one thing you might want to examine is the X-MS-Exchange-Organization-Recipient-P2-Type: mail header that should get set in your internal to internal scenario (you need to look at the PidTagTransportMessageHeaders extended property to see it)
I'm trying to pull the latest sends from all my campaigns in Mailchimp via the 3.0 API. The only way I seem to be able to do this is:
1) Search for a given member by email
/3.0/search-members?query=joe#example.com
2) Get the member ID and request their activity
3.0/lists/{LIST ID}/members/{USER ID}/activity
3) Pull the content of the email in their activity feed:
3.0/campaigns/{CAMPAIGN ID}/content
The problem with this is that I need to know the user's email in advance and then search by each user individually, meaning many wasted of API calls.
Is there an endpoint for campaigns that I can request the last sends for a given date range?
The /campaigns endpoint returns campaigns for a given list and each returned object does include a recipients property.
You may also want to checkout:
/search-campaigns
And:
/reports/{campaign_id}/sent-to
I want the recipient of my SMS text message to see the name of my business, rather than the phone number. How is this possible? I am currently using Twilio, but I am open to suggestions involving other services.
For those of you who have looked at #philnash s answer and still having problems, please read this. I'm using the twilio-ruby gem, and am in the UK.
I see a lot of places state that:
all you need to do is replace the from parameter.
This is not true!
Step 1
Contact Twilio and have them enabled it on your account.
Step 2
The second step is to make sure that to number you are using has the correct country code, 0779XXXXXXX and 779XXXXXXX are enough to send a text message when specifying a from number that has been previously purchased. The purchased number has a country of origin and therefore Twilio know to prefix it with the correct country code. However, an alphanumeric sender has no from number, and therefore no country of origin.
Using 0779XXXXXXX as the To param. Returns the error:
The 'To' number 0779XXXXXXX is not a valid phone number.
While technically correct, it isn't incorrect, it's just missing the country code.
Using 779XXXXXXX as the To param. Returns this error: The 'To' phone number: +1779XXXXXXX, is not currently reachable using the 'From' phone number: Foo via SMS. +1 is the USA phone prefix. The USA doesn't have an option to send as alphanumeric. This is how I stumbled onto the fix.
TLDR;
1. Contact Twilio to get them to enable it on your account
2. Make sure you prefix with the country code.
I have found three services (not Twilio) that appear to address the question:
Nexmo
Plivo
smsmessagesender
The above services support dynamic alphanumeric sender ID for outbound SMS, so you should be able to send a combination of 11 alpha-numeric characters as the sender ID of your message. Note the emphasis on outbound SMS. It appears that receiving incoming SMS on an alphanumeric sender ID is not possible.
If anyone has more experience with these services, please share.
Edit: Note that the availability of these services also depends on the laws of the jurisdiction where the services are to be used.
Twilio developer evangelist here.
I know this is a good few months since you asked this, but I wanted to update the possible answers for completeness. When you asked this in November 2014 it was not possible to send SMS messages from Twilio using an alphanumeric sender ID.
However, since May 2015 it has been possible to do so. All you need to do is replace the phone number as the From parameter of the API call to send a message with the text you want the sender ID to be. This currently works when sending SMS messages to 145 countries.
If I was doing this in Ruby, it would look like:
account_sid = YOUR_TWILIO_ACCOUNT_SID
auth_token = YOUR_TWILIO_AUTH_TOKEN
recipient_phone_number = RECIPIENT_PHONE_NUMBER
client = Twilio::REST::Client.new(account_sid, auth_token)
client.messages.create(
from: "ALPHANUMERICID",
to: recipient_phone_number,
body: "Hello World!"
)
Edit
Please note, that to use alphanumeric sender IDs on your Twilio account you need to have your account enabled. To do so, please contact twilio support with your account SID to request access.
As FullStack said, you can consider using another SMS API for this.
Nexmo, where I work, offers a high quality messaging service including the support of dynamic sender id. You can use any alphanumeric string to describe your application or brand where supported by carriers (where there are no restrictions on alphanumeric sender ids).
Some countries, such as the United States, don't allow alphanumeric sender ids. Other countries allow it, but have special restrictions that we take into account & work around to ensure maximum delivery.
You can find the full list of alpha-numeric sender ID compatible countries, along with carrier restrictions, here.
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
'api_key' => API_KEY,
'api_secret' => API_SECRET,
'to' => YOUR_NUMBER,
'from' => "AppName",
'text' => 'Hello'
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
How do I fill in the send message method for Twilio, I know how to fill in the from, to and body. the only part that befuddles me is the System.Action. Please help.
System.Action is basicly a method.
You can call SendSmsMessage this way:
Twilio.TwilioRestClient.SendSmsMessage("from", "to", "message", (smsmessage) => { });
I'm not familiar with Twilio or the SendSmsMessage method, but I suspect, that this method gets called when SendSmsMessage finishes or something like that. In this case, smsmessage is a parameter that is usable in the Action.
You can read more about System.Action here and about c# lamdas in general here