返回php调用web services两种方法soap和curl

curl_init  时间:2021-04-19  阅读:()

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);

}

香港ceranetworks(69元/月) 2核2G 50G硬盘 20M 50M 100M 不限流量

香港ceranetworks提速啦是成立于2012年的十分老牌的一个商家这次给大家评测的是 香港ceranetworks 8核16G 100M 这款产品 提速啦老板真的是豪气每次都给高配我测试 不像别的商家每次就给1核1G,废话不多说开始跑脚本。香港ceranetworks 2核2G 50G硬盘20M 69元/月30M 99元/月50M 219元/月100M 519元/月香港ceranetwork...

香港CN2云服务器 1核 2G 35元/月 妮妮云

妮妮云的来历妮妮云是 789 陈总 张总 三方共同投资建立的网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑妮妮云的市场定位妮妮云主要代理市场稳定速度的云服务器产品,避免新手购买云服务器的时候众多商家不知道如何选择,妮妮云就帮你选择好了产品,无需承担购买风险,不用担心出现被跑路 被诈骗的情况。妮妮云的售后保证妮妮云退款 通过于合作商的友好协商,云服务器提供2天内全额退款到网站余额,超过2天...

DMIT:香港国际线路vps,1.5GB内存/20GB SSD空间/4TB流量/1Gbps/KVM,$9.81/月

DMIT怎么样?DMIT是一家美国主机商,主要提供KVM VPS、独立服务器等,主要提供香港CN2、洛杉矶CN2 GIA等KVM VPS,稳定性、网络都很不错。支持中文客服,可Paypal、支付宝付款。2020年推出的香港国际线路的KVM VPS,大带宽,适合中转落地使用。现在有永久9折优惠码:July-4-Lite-10OFF,季付及以上还有折扣,非 中国路由优化;AS4134,AS4837 均...

curl_init为你推荐
计算机网络实验系统我的"点绛唇"支持ipad支持ipadwin10445端口win7系统不能被telnet端口号,端口、服务什么全都开了css下拉菜单如何用css3做导航栏下拉菜单fusionchartsfusioncharts怎么生成图片至excelgoogleadsense如何通过Google adsense???css选择器请给出三种Css选择器并举例说明google分析google analysis干什么用的?
汉邦高科域名申请 vps.net 128m内存 softbank官网 日志分析软件 空间出租 微信收钱 国外代理服务器软件 php空间购买 河南移动m值兑换 四川电信商城 可外链的相册 godaddy空间 双11促销 博客域名 石家庄服务器 godaddyssl 美国主机 comodo 香港打折信息 更多