Discuz教程网

PHP 手机归属地查询 api

[复制链接]
authicon dly 发表于 2011-9-1 11:18:10 | 显示全部楼层 |阅读模式
代码如下:

  1. <?php
  2. header("Content-Type:text/html;charset=utf-8");
  3. if (isset($_GET['number'])) {
  4. $url = 'http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo';
  5. $number = $_GET['number'];
  6. $ch = curl_init();
  7. curl_setopt($ch, CURLOPT_URL, $url);
  8. curl_setopt($ch, CURLOPT_POST, true);
  9. curl_setopt($ch, CURLOPT_POSTFIELDS, "mobileCode={$number}&userId=");
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11. $data = curl_exec($ch);
  12. curl_close($ch);
  13. $data = simplexml_load_string($data);
  14. if (strpos($data, 'http://')) {
  15. echo '手机号码格式错误!';
  16. } else {
  17. echo $data;
  18. }
  19. }
  20. ?>

  21. <form action="mobile.php" method="get">
  22. 手机号: <input type="text" name="number" /> <input type="submit" value="提交" />
  23. </form>
复制代码







上一篇:PHPmyadmin 常用选项设置详解版
下一篇:PHP 抓取新浪读书频道的小说并生成txt电子书的代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 16:25

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表