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);
}
我们先普及一下常识吧,每年9月的第一个星期一是美国劳工节。于是,有一些服务商会基于这些节日推出吸引用户的促销活动,比如RackNerd有推出四款洛杉矶和犹他州独立服务器,1G带宽、5个独立IP地址,可以配置Windows和Linux系统,如果有需要独立服务器的可以看看。第一、劳工节促销套餐这里有提供2个套餐。两个方案是选择犹他州的,有2个方案是可以选择洛杉矶机房的。CPU内存SSD硬盘配置流量价格...
rangcloud怎么样?rangcloud是去年年初开办的国人商家,RangCloud是一家以销售NAT起步,后续逐渐开始拓展到VPS及云主机业务,目前有中国香港、美国西雅图、韩国NAT、广州移动、江门移动、镇江BGP、山东联通、山东BGP等机房。目前,RangCloud提供香港CN2线路云服务器,电信走CN2、联通移动直连,云主机采用PCle固态硬盘,19.8元/月起,支持建站使用;美国高防云...
今天CloudCone发布了最新的消息,推送了几款特价独立服务器/杜甫产品,美国洛杉矶MC机房,分配100Mbps带宽不限流量,可以选择G口限制流量计划方案,存储分配的比较大,选择HDD硬盘的话2TB起,MC机房到大陆地区线路还不错,有需要美国特价独立服务器的朋友可以关注一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2...