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);
}
韩国服务器怎么样?韩国云服务器租用推荐?韩国服务器距离中国近,有天然的地域优势,韩国服务器速度快而且非常稳定!有不少有亚洲市场的外贸公司选择韩国服务器开拓业务,韩国服务器因自身的优势也受到不少用户的青睐。目前的IDC市场上,韩国、香港、美国三个地方的服务器几乎占据了海外服务器的百分之九十以上。韩国服务器相比美国服务器来说速度更快,而相比香港机房来说则带宽更充足,占用市场份额非常大。那么,韩国服务器...
gcorelabs提供美国阿什本数据中心的GPU服务器(显卡服务器),默认给8路RTX2080Ti,服务器网卡支持2*10Gbps(ANX),CPU为双路Silver-4214(24核48线程),256G内存,1Gbps独享带宽仅需150欧元、10bps带宽仅需600欧元,不限流量随便跑吧。 官方网站 :https://gcorelabs.com/hosting/dedicated/gpu/ ...
justhost怎么样?justhost是一家俄罗斯主机商,2006年成立,提供各种主机服务,vps基于kvm,有HDD和SSD硬盘两种,特色是200Mbps不限流量(之前是100Mbps,现在升级为200Mbps)。下面是HDD硬盘的KVM VPS,性价比最高,此外还有SSD硬盘的KVM VPS,价格略高。支持Paypal付款。国内建议选择新西伯利亚或者莫斯科DataLine。支持Paypal付...