2012-03-12 146 views
1

在我的公司,我們需要通過短信網關發送一些提醒,我已經使用Nexmo API和java。它工作完美,但是我們公司無法購買這項服務,所以我在想;有沒有免費的短信網關?用java發送免費短信

+0

如果每封郵件的成本問題,以發送短信,而你正在做一個大批量,請聯繫Nexmo,看看有什麼可以完成(*免責聲明:我與Nexmo *合作)。或者,如果這些警報是針對您的用戶的,也許他們可以註冊(如果他們需要該功能)並將其API憑據傳遞給您。 – 2012-03-13 03:04:47

+0

@TimLytle你能給我支持嗎? – fers 2012-03-13 14:52:37

+0

@fers在此處添加一張票:https://nexmo.zendesk.com/我會確保您收到回覆。 – 2012-03-13 15:49:27

回答

0

您找到的免費提供商可能會將您限制爲某些數量的消息或施加其他限制。但是,許多提供商支持您可能可以用來發送消息的email gateway。例如,如果你有一個手機號碼並且知道提供者(在這個例子中是Verizon無線),那麼你可以發送一封電子郵件到[email protected],它將作爲一條短信發送給手機。這可能是您考慮的另一種選擇。

0

下面的程序是用來使用site2sms網關

import java.io.BufferedReader; 
import java.io.InputStreamReader; 
import java.net.URL; 
import java.net.URLConnection; 

public class SendSMS 
{ 
static String SMSApi = "https://site2sms.p.mashape.com/index.php?uid=9095393259&pwd=554182&phone=9751931673&msg=hai"; 
static String head = "aVi7utR6ZUkGLFkGRwXxd4wLsXz7c1QQ"; 
public static void main(String[] args) 
{ 
    try 
    { 
     String url = SMSApi; 
     String smsApiResponse = sendMySMS(url); 
     System.out.println(smsApiResponse); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 
} 

private static String sendMySMS(String url) 
{ 
    StringBuilder output = new StringBuilder(); 
    try 
    { 
     URL hp = new URL(url); 
     System.out.println(url); 
     URLConnection hpCon = hp.openConnection(); 
     hpCon.setRequestProperty("X-Mashape-Authorization", head); 
     BufferedReader in = new BufferedReader(new InputStreamReader(hpCon.getInputStream())); 
     String inputLine; 
     while ((inputLine = in.readLine()) != null) 
      output.append(inputLine); 
     in.close(); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 
    return output.toString(); 
} 

}