I wrote an article about it, here it is:
anton
I wrote an article about it, here it is:
anton
I am trying out your program using Twilio as the SMS gateway. So far your program is great and I really appreciate your effort.
However, I have a problem sending the SMS via Twilio if I try to use alphanumeric sender code (like CPNOTIFY) as sender instead of long code (phone number subscribed from Twilio). Twilio will reply error 400:
L2 twilio_hook_sendsms # sent smslog_id:32 message_id: status:400 error:400|21212|The ‘From’ number CPNOTIFY is not a valid phone number, shortcode, or alphanumeric sender ID. smsc:[twilio1]
The alphanumeric sender code is working if I use command line curl to send message.
Your code looks fine to me:
if ($sms_sender && $sms_to && $sms_msg) { $url = $plugin_config['twilio']['url'] . '/2010-04-01/Accounts/' . $plugin_config['twilio']['account_sid'] . '/SMS/Messages.json'; $data = array( 'To' => $sms_to, 'From' => $sms_sender, 'Body' => $sms_msg ); if (trim($plugin_config['twilio']['callback_url'])) { $data['StatusCallback'] = trim($plugin_config['twilio']['callback_url']); } if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERPWD, $plugin_config['twilio']['account_sid'] . ':' . $plugin_config['twilio']['auth_token']); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $returns = curl_exec($ch); curl_close($ch);
Any idea?
Hi,
The error message came from Twilio, here it is:
Please check the possible solution part.
About alpha sender id on Twilio:
Anton
Oh wait, you said that using curl its working. Ic ic, Ill check it.
Can you share your command line curl (redact access informations)?
Anton
I use the following and it works:
curl -XPOST h ttps://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXX/Messages.json --data-urlencode “To=+8888888888” --data-urlencode “From=CPNOTIFY” --data-urlencode “Body=test” -u ‘ACXXXXXXXXXXXXX:MYAUTHCODE’
I use /SMS/Messages.json, without /SMS/ it will be limited to 160 chars:
But do try that, edit your playSMS and remove /SMS/
Anton
It works by removing SMS. So it will restrict to 160 characters now?
Yes. You can add some logic there, for example if the message length or if the sender is not msisdn then use without /SMS/, otherwise add it.
Please confirm this with Twilio, maybe they have other option to solve this.
Anton
Yeah. I reported to Twilio also.
Wait, I think I was wrong, in master version (soon to be 1.4.4) its already without SMS/ so no logic needed or fixes needed. If you’re not using 1.4.4-alpha1/master version then you need to update the code manually, remove SMS/.
anton
Noted. I am using 1.4.3 now. I will manually modify the code.
This integration type with Twilio could be used even for Whatsapp interaction?