【问题标题】:SMS sending through ASP.Net API通过 ASP.Net API 发送短信
【发布时间】:2015-06-30 08:37:06
【问题描述】:

短信服务提供商提供了发送短信的链接。这个链接我把它放在我的网站上,但在那个链接中,我必须通过标签动态传递电话号码和价格。谁能帮帮我吗。 我正在使用的代码是

var cli = new System.Net.WebClient();
string price = "230";
string number = "9999999999";

cli.DownloadString(@"http://bhashsms.com/api/sendmsg.php?user=ABCXYZ&pass=*****&sender=BSHSMS&phone=9999999999&text=Test SMS YOUR Order HAs Been Placed OF RS. 230 Successfully&priority=ndnd&stype=normal");

【问题讨论】:

  • 您能否举例说明预期结果的样子?问题是简单地构建一个字符串来传递吗cli.DownloadString()

标签: c# asp.net


【解决方案1】:

只需将内容放在字符串中的相应位置即可传递给cli.DownloadString()。这个例子展示了如何使用string.Format()

var cli = new System.Net.WebClient();
string price = "230";
string number = "9999999999";

var format = @"http://bhashsms.com/api/sendmsg.php?user=ABCXYZ&pass=*****&sender=BSHSMS&phone={0}&text=Test SMS YOUR Order HAs Been Placed OF RS. {1} Successfully&priority=ndnd&stype=normal"

cli.DownloadString(string.Format(format, number, price));

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-18
相关资源
最近更新 更多