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);
}
pacificrack怎么样?pacificrack商家发布了七月最新优惠VPS云服务器计划方案,推出新款优惠便宜VPS云服务器采用的是国产魔方管理系统,也就是PR-M系列,全系基于KVM虚拟架构,这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10以及Linux等操作系统,最低配置为1核心2G内存1Gbps带宽1...
v5.net一直做独立服务器这块儿的,自从推出云服务器(VPS)以来站长一直还没有关注过,在网友的提醒下弄了个6G内存、2核、100G SSD的美国云服务器来写测评,主机测评给大家趟雷,让你知道v5.net的美国云服务器效果怎么样。本次测评数据仅供参考,有兴趣的还是亲自测试吧! 官方网站:https://v5.net/cloud.html 从显示来看CPU是e5-2660(2.2GHz主频),...
特网云为您提供高速、稳定、安全、弹性的云计算服务计算、存储、监控、安全,完善的云产品满足您的一切所需,深耕云计算领域10余年;我们拥有前沿的核心技术,始终致力于为政府机构、企业组织和个人开发者提供稳定、安全、可靠、高性价比的云计算产品与服务。公司名:珠海市特网科技有限公司官方网站:https://www.56dr.com特网云为您提供高速、稳定、安全、弹性的云计算服务 计算、存储、监控、安全,完善...