<?php
function  inquiry_number_infor($phonenumber)
/*
*传入手机号码,通过API的到xml格式数据,对xml进一步解析,最后返回相应的号码信息的数组。
*
*@param  string  $phonenumber
*
*@return  array
*/
  
{
      $url                    = "http://api.showji.com/Locating/default.aspx?m=$phonenumber&output=xml&callback=querycallback";
    $lines_array              = file($url);
    $lines_string             = implode('', $lines_array); 
    echo htmlspecialchars($lines_string);
    echo "</br>";
    $p                        = xml_parser_create();
    xml_parse_into_struct($p, $lines_string, $vals, $index);
    xml_parser_free($p);
    $return_arr                = array();
    foreach($vals as $val)
    {
         $key                  = $val["tag"];
         if($key != "QUERYRESPONSE")
         {
             $value             = $val["value"];
             $return_arr[$key]  =$value;
         }
         if($key === "QUERYRESULT" && $value === "False") break;
    }
    return $return_arr;
}
$ret                  = inquiry_number_infor("11210982674");
//$ret                = inquiry_number_infor("15210982674");
print_r($ret);

 

相关文章:

  • 2022-02-13
  • 2021-06-19
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-11-23
  • 2021-12-05
相关资源
相似解决方案