JAVA調用基站雲介面調用執行個體

來源:互聯網
上載者:User

標籤:

 /**

 * @(#)jizhanyun.com for java * * 基站雲平台介面示範FOR JAVA * * @基站雲 * @version 1.00 */import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.net.*; import java.io.IOException; public class API {        public static String apikey    = "1ATS2C6D9FFF0825DA88B864A3D1E034"; //apikey 基站雲平台擷取    public static String mnc       = "0";                                //mnc    public static String lac       = "20857";                            //lac    public static String cell      = "59051";                            //cell     public static String getWebData(String domain) {        StringBuffer sb = new StringBuffer();        InputStream is = null;        InputStreamReader isr = null;        BufferedReader in = null;        try {            java.net.URL url = new java.net.URL(domain);            is = url.openStream();            isr = new InputStreamReader(is,"utf-8");            in = new BufferedReader(isr);            String line;            while ((line = in.readLine()) != null) {                sb.append(line).append("\n");            }            in.close();                    } catch (IOException e) {            e.printStackTrace();        }finally {            try {                if(in!=null){                    in.close();                    in=null;                }                if(isr!=null){                    isr.close();                    isr=null;                }                if(is!=null){                    is.close();                    is=null;                }            } catch (IOException e) {                e.printStackTrace();            }        }        return sb.toString();    }        public static void main(String[] args) {        String data=getWebData("http://www.jizhanyun.com/api/?mnc="+mnc+"&lac="+lac+"&cell="+cell+"&ishex=10&type=1&apikey="+apikey);        String code="";        String about="";        String lng="";        String lat="";        String glng="";        String glat="";        String address="";        if(data!=""){            String[] arr=data.split("\\|");            code=arr[0];            if(code.equals("001")){                lng=arr[2];                lat=arr[3];                glng=arr[4];                glat=arr[5];                address=arr[6];            }else{                about=arr[1];            }        }                System.out.println("狀態:"+code);        System.out.println("說明:"+about);        System.out.println("經度:"+lng);        System.out.println("緯度:"+lat);        System.out.println("Google地圖經度:"+glng);        System.out.println("Google地圖經度:"+glat);        System.out.println("地址:"+address);      }}

JAVA調用基站雲介面調用執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.