php调用ws接口代码

一、定义变量

define("CUSTOMER_AIS", "http://localhost:8080/ais/customer");

二、公用方法

class commodity
    {
        
        function mis_user($interfaceId,$arg){
            //$arg = json_encode($arg);
            $url = constant("CUSTOMER_AIS")."?interfaceId=$interfaceId&arg=$arg";
            $line = "";
            $file_handle = fopen($url, "r");
            if(empty($file_handle)){
                die("输入错误,文件不存在");
            }
            while (!feof($file_handle)) {
               $line .= fgets($file_handle);
            }
            fclose($file_handle);
            return $line;
        }
}

三、调用类中的方法

方式一:

$aisObj = new commodity();

$aisObj->mis_user("7", "{\"bankCode\":\"123456"}");

方式二:

commodity::mis_user("7", "{\"bankCode\":\"123456"}");

猜你喜欢

转载自handly-eye.iteye.com/blog/2345267
今日推荐