Mobile phone number attribution to query

Source: Internet
Author: User

Objective:

I am learning PHP, do this is also learn from Baidu examples and other programs. Interested small partners can communicate with each other

First, the HTML query page

        

Then it's the query Display page (using the Curl operation)

1<?PHP2 Header(' Content:text/html;charset:utf-8 ');3 $ch=curl_init ();4 $phone=isset($_post[' Phone ']?$_post[' Phone ']:false;5 $url= ' http://apis.baidu.com/apistore/mobilenumber/mobilenumber?phone= '.$phone;6 $header=Array(7' Apikey: Fill in your API ',8 );9 //add Apikey to HeaderTencurl_setopt ($ch, Curlopt_httpheader,$header); Onecurl_setopt ($ch, Curlopt_returntransfer, 1); A //executing an HTTP request -curl_setopt ($ch, Curlopt_url,$url); - $res= Curl_exec ($ch); the  - $jsondata=json_decode ($res,true); - if($jsondata&&$jsondata[' Errnum ']==0){ -         Echo' Query status: ',$jsondata[' retmsg '], ' <br/> '; +         Echo' Enquiry number: ',$jsondata[' Retdata '] [' Phone '], ' <br/> '; -         Echo' Query number segment: ',$jsondata[' Retdata '] [' prefix '], ' <br/> '; +         Echo' Operator: ',$jsondata[' Retdata '] [' Supplier '], ' <br/> '; A         Echo' Attribution to the province: ',$jsondata[' Retdata '] [' Province '], ' <br/> '; at         Echo' Attribution to the city: ',$jsondata[' Retdata '] [' City '], ' <br/> '; -         Echo' Number package: ',$jsondata[' Retdata '] [' Suit '], ' <br/> '; -     } - Else{ -     Echo' <script>alert ("Query Failed"); location.href= "index.html" </script> '; -}
return result is
Query Status: Success Query number:15210011578 Query number segment:1521001 Operator: Mobile Attribution Province: Beijing City: Beijing number package: 152 Card

Mobile phone number attribution to query

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.