php调用w eb s ervic es两种方法s oap和curl
以http://www.w ebxml.c om.c n/zh_c n/index.as px
一、使用soap调用
?p hp
//服务器支持soap扩展:
/*Example 1:
$c lient=new SoapClient(http://fy.w ebxml.c om.cn/w ebs ervic es/EnglishChines e.asmx?w s dl$parameters=array(w ordKey=test
//中英文双向翻译返回数据数组
$result=$c lient-Trans latorString($parameters);echo preprint_r($result-TranslatorStringResult).br/echo/pre
//中英文双向翻译返回数组含句子例子
$result1=$client-Translator($parameters);echo preprint_r($result1-TranslatorResult).br/echo/pre
//获得候选词
$result2=$c lient-SuggestWord($parameters);echo preprint_r($result2-SuggestWordResult).br/
echo/pre
//获得朗读MP3字节流,返回数据字节数组Byte[]
$result3=$c lient-GetMp3($parameters);echo preprint_r($result3).br/echo/pre
$c lient = newSoapClient(http://w ebs ervic e.w ebxml.c om.cn/WebServic es/IpAddres s S earchWebS ervic e.asmx?ws dl
$param=array(‘theIpAddres s’=‘202.96.134.33’);
$res ult=$c lient-getCountryCity ByIp($param);echo preprint_r($result-getCountryCity ByIpResu lt);echo/pre
$result 1=$c lient-getGeoIPContext($param);echo preprint_r($result 1);echo/pre
$result2=$c lient-getVers ionTime(echo preprint_r($result2);echo/pre
//Ex amp le 3:
$c lient = newSoapClient(http://w ebs ervic e.w ebxml.c om.cn/WebS ervic es/MobileCodeWS.asmx?ws dl
//获得国内手机号码归属地省份、地区和手机卡类型信息
$parm=array(‘mobileCode’=‘1367007’ ,’userID’=
$result=$c lient-getMobile CodeInfo($parm);echo($result-getMobileCodeInfoResult).br
//获得国内手机号码归属地数据库信息
$result 1=$c lient-getDatabas eInfo($parm);print_r($result 1).br
//获取SOAP类型列表(Returns list of SOAP types )echo‘preprint_r($c lient-__getTyp es ()) ;echo‘ /pre
//获取w ebs ervic e提供的函数echo‘preprint_r($c lient-__getFunc tions ()) ;echo‘ /pre
//服务器不支持soap扩展的情况下可引入网上开源的类库
?
二、使用curl中POST
?p hpcPost(‘l8200352367’);
*使用CURL中P O S T方式提交数据
*@param string$xml要提交的$xml数据function c Post($phone){
$curlPost=mobileCode=$phone userID=
$ch=curl_init();//初始化curl会话返回一个句柄curl_s etopt($ch, CURLOPT_URL,http://w ebs ervic e.w ebxml.c om.cn/WebServic es/Mobile CodeWS.asmx/getMobileCodeInfocurl_s etopt($c h, CURLOPT_POST, 1);//启用时会发送一个常规的POST请求类型为applic ation/x-www-form-urlenc oded就像表单提交的一样curl_s etopt($ch,CURLOPT_POSTFIELDS, $curlPost);curl_s etopt($ch,CURLOPT_RET URNTRANSFER, 1);//将curl_exec()获取的信息以文件流的形式返回而不是直接输出
$res=curl_exec($ch);curl_close($ch);v ar_dump($r es);
}
racknerd当前对美国犹他州数据中心的大硬盘服务器(存储服务器)进行低价促销,价格跌破眼镜啊。提供AMD和Intel两个选择,默认32G内存,120G SSD系统盘,12个16T HDD做数据盘,接入1Gbps带宽,每个月默认给100T流量,5个IPv4... 官方网站:https://www.racknerd.com 加密数字货币、信用卡、PayPal、支付宝、银联(卡),可以付款! ...
BuyVM针对中国客户推出了China Special - STREAM RYZEN VPS主机,带Streaming Optimized IP,帮你解锁多平台流媒体,适用于对于海外流媒体有需求的客户,主机开设在拉斯维加斯机房,AMD Ryzen+NVMe磁盘,支持Linux或者Windows操作系统,IPv4+IPv6,1Gbps不限流量,最低月付5加元起,比美元更低一些,现在汇率1加元=0.7...
俄罗斯vps速度怎么样?俄罗斯vps云主机节点是欧洲十大节点之一,地处俄罗斯首都莫斯科,网络带宽辐射周边欧洲大陆,10G专线连通德国法兰克福、法国巴黎、意大利米兰等,向外连接全球。俄罗斯vps云主机速度快吗、延迟多少?由于俄罗斯数据中心出口带宽充足,俄罗斯vps云主机到全球各地的延迟、速度相对来说都不错。今天,云服务器网(yuntue.com)小编介绍一下俄罗斯vps速度及俄罗斯vps主机推荐!俄...