如何通过SMPP直接发送短信?我的供应商提供了一个SMPP接口来发送短信,我该如何连接它?是否有任何图书馆或例子可以教育我使用SMPP发送?也许使用PHP?或C#?通过SMPP发送短信
回答
用Java编写的Logica SMPP project可以教你关于这个问题。除此之外,SMPP Wikipedia page上的项目列表可能会有类似的用途。
我已经使用了DevShock的客户端库几年,但该公司似乎已从视图中消失。
快速谷歌打开了这一个,但:
http://www.inetlab.ru/Products/ALT.SMS.SmppClient.aspx。
看起来很简单,并且附带了C#和VB.Net示例以及一些体面的文档。
希望有所帮助。
我认为最好的choise是jsmpp库。它有很好的例子,很多低级的事情发生在幕后,你可以专注于你的业务逻辑。
Devshock成分是凉......他们释放我想在一些点源?
我相信我还是那样。
不过,自己写的lib SMPP并不难......
SMPP 3.4规范是相当直截了当。
你基本上是在做三两件事:
- 管理套接字连接 - .NET堆栈,使这很容易和高效
- 发送正确格式的PDU
- 解码接收的字节到PDU
奥拉,如果你仍然需要这个,你可以给我发邮件。
干杯。
编辑 一些供应商,如我使用(高科技INFOSYSTEMS)还为您提供一个HTTP网关,通过它您可以发布您的流量
您可以寻求作为替代SMPP。
我见过的SMPP经历的一个缺点是频繁断开连接是您的网络连接不稳定。
HTTP网关选项不会受此影响,速度也一样快。
我使用Kannel作为SMPP,将kannel连接到smpp服务器:link。
这是我kannel.conf:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
status-password = foo
log-file = "/var/log/kannel/bearerbox.log"
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
access-log = "/var/log/kannel/smsaccess.log"
#SMSC CONNECTION
group=smsc
smsc=smpp
smsc-id=ID1
host=130.1.1.50
port=5016
transceiver-mode = 1
source-addr-ton = 1
source-addr-autodetect = 0
dest-addr-npi = 1
dest-addr-ton = 1
smsc-username = "user"
smsc-password= "pass"
system-type= "system"
#SMSBOX SETUP
group = smsbox
bearerbox-host = 127.0.0.1
bearerbox-port = 13001
sendsms-port = 13013
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/smsaccess.log"
#SEND-SMS USERS
group = sendsms-user
username = user
password = pass
#SERVICES
group = sms-service
keyword = default
text = "Su mensaje ha sido procesado"
concatenation = true
catch-all = true
accept-x-kannel-headers = true
get-url = "http://localhost/kannel/receivesms.php?sender=%p&text=%b"
发送短信:
curl "http://localhost:13013/cgi-bin/sendsms?user=xxxxxx&pass=yyyyy&to=56976808016&text=tes"
您可以使用SMPPCli这是一个命令行SMPP短信发送者。 您可以从http://www.kaplansoft.com/download.html
以下是在C#中使用smpp协议的简单示例代码。
顺便说一句ardan studio dll有一些关于数据编码和解码的问题。
TON和NPİ在ardan studio dll中被赋予静态,所以我们改变了它然后我们使用了这个代码,否则它的工作原理,但你不能使用不同的字符集。
using ArdanStudios.Common.SmppClient;
using ArdanStudios.Common.SmppClient.App;
public class SMPPClientService
{
public static readonly object CounterLock = new object();
private static bool isConnected = false;
private ESMEManager SMPPConnectClient()
{
var smppServerPort = Library.GetAppSetting(SMPP_Server_Port).Split(';');
string server = "xxx.xx.xx.xxx";
short port = 6101;
string shortLongCode = "MESSAGETİTLE";
string systemId = "USername";
string password = "password";
DataCodings dataCoding = DataCodings.Latin1;
ESMEManager connectionManager = new ESMEManager("EricssonTest", shortLongCode, new ESMEManager.CONNECTION_EVENT_HANDLER(ConnectionEventHandler), null, null, null, null, new ESMEManager.LOG_EVENT_HANDLER(LogEventHandler), null);
connectionManager.AddConnections(1, ConnectionModes.Transmitter, server, port, systemId, password, "Transmitter", dataCoding);
return connectionManager;
}
private static void LogEventHandler(LogEventNotificationTypes logEventNotificationType, string logKey, string shortLongCode, string message)
{
}
private static void ConnectionEventHandler(string logKey, ConnectionEventTypes connectionEventType, string message)
{
if (ConnectionEventTypes.Connected == connectionEventType)
{
lock (CounterLock)
{
isConnected = true;
}
}
}
private string Msisdn(string receiver)
{
var tmp = receiver.Replace("/", "")
.Replace(" ", "")
.Replace("-", "");
if (tmp.Length == 10)
return 90 + receiver;
if (tmp.Length == 11 && tmp[0] == '0')
return 9 + tmp;
return tmp;
}
public int SMPPSendMessage(string messageText, string phoneNumber)
{
var result = 0;
var pql = new PSmsSendLogs();
try
{
using (var connectionManager = SMPPConnectClient())
{
phoneNumber = Msisdn(phoneNumber);
DataCodings submitDataCoding = DataCodings.Latin1;
DataCodings encodeDataCoding = DataCodings.Latin1;
List<SubmitSm> submitSm = null;
List<SubmitSmResp> submitSmResp = null;
while (true)
{
Thread.Sleep(1000);
if (isConnected)
{
*// put code here to wait until connection is being establish.İt works Async so it coulnt be connected when we called send method*
break;
}
}
result = connectionManager.SendMessageLarge(phoneNumber, null, Ton.Alphanumeric, Npi.Unknown, submitDataCoding, encodeDataCoding, messageText, out submitSm, out submitSmResp);
}
}
catch (Exception ex)
{
result = 0;
}
return result;
}
#endregion
}
- 1. 通过SMPP与骆驼发送短信
- 2. 通过SMPP发送多个短信
- 3. ActiveMQ&Camel&SMPP:发送短信
- 4. 通过SMPP接收短信
- 5. 通过SMPP发送Unicode短消息
- 6. 如何使用mblox通过SMPP发送短信?
- 7. 通过SMPP协议在java中发送短信
- 8. 不能通过SMPP发送多部分短信在java中
- 9. 无法通过smpp帐户发送短信
- 10. 发送短信smpp协议错误
- 11. 通过PHP发送短信/短信
- 12. 通过PHP发送短信
- 13. 发送短信通过.net
- 14. 通过IP发送短信
- 15. 通过NFC发送短信
- 16. 通过应用程序发送短信
- 17. 在ios上通过Twilio发送短信?
- 18. Android:通过闹钟发送短信
- 19. 通过Iphone,MFMessageComposeViewController发送短信
- 20. 通过短信发送地址
- 21. 通过iPhone5的发送短信
- 22. 通过Twilio发送短信POST错误
- 23. 通过JavaScript发送短信到手机
- 24. 通过php,AT命令发送短信
- 25. 通过免费网关发送短信
- 26. 通过短信发送GPS坐标
- 27. 使用jsp通过HTTP发送短信
- 28. 通过短信发送当前位置
- 29. J2ME:通过短信发送图像
- 30. 通过电子邮件发送短信