1.注册来信码:@官网
注册后
1.1,开发者选项-开发设置,获取accesskey\secretkey
1.2,融合通讯-IM及时通讯,开启IM
2.微信关注公众号"来信码",手机绑定
3.代码
package yanantest; import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.ParseException; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; public class TestImlaixin { public static void main(String[] args) { //测试时请将替换你的useraccesskey、、usersecretkey、、mobile //url1和url2作用一样,个人猜测url1是现在的语法,url2是老版本。get和post结果一样。httpclient个人学的不精通,不推荐哪种方式了 //String url1="https://imlaixin.cn/Api/send/data/json?accesskey=useraccesskey&secretkey=usersecretkey&mobile=1******76**&content=你好,world"; //String url2="http://sms.bechtech.cn/Api/send/data/json?accesskey=useraccesskey&secretkey=usersecretkey&mobile=1******76**&content=你好,world"; //testGet(url1); //testPost(url2); } @SuppressWarnings("finally") public static String testGet(String url){ @SuppressWarnings({ "resource", "deprecation" }) HttpClient httpClient=new DefaultHttpClient(); HttpGet get= new HttpGet(url); get.setHeader("User-Agent", "Mozilla/5.0"); String string=""; try { HttpResponse response = httpClient.execute(get); HttpEntity entity = response.getEntity(); string = EntityUtils.toString(entity, "UTF-8"); System.out.println(response.getStatusLine().getStatusCode()); get.releaseConnection(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ return string; } }@SuppressWarnings("finally") public static String testPost(String url){ @SuppressWarnings({ "resource", "deprecation" }) HttpClient httpClient=new DefaultHttpClient(); HttpPost post=new HttpPost(url); StringEntity se = new StringEntity("", "UTF-8"); post.setHeader("User-Agent", "Mozilla/5.0"); post.setEntity(se); String string=""; try { HttpResponse response = httpClient.execute(post); HttpEntity entity = response.getEntity(); string = EntityUtils.toString(entity, "UTF-8"); System.out.println(response.getStatusLine().getStatusCode()); post.releaseConnection(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ return string; } } }