About PHP implementation of mobile phone attribution to query video tutorial resource recommendations

Source: Internet
Author: User
Now a variety of Web applications, as a programmer, how can not be a defensive? "PHP implementation of mobile phone attribution Search Video Tutorial" will take you from 0 to develop a complete Web application, from framework to process analysis and data caching, I believe you learned this lesson after the harvest is not only learned to develop an application.

Course Play Address: http://www.php.cn/course/412.html

The teacher's lecture style:

The teacher lively image, witty witty, witty, touching. A vivid image of the metaphor, like the finishing touch, to the students to open the door of wisdom, a proper sense of humor, attracting students to smile, such as drinking a cup of glycol wine, to the aftertaste and nostalgia, the philosopher's motto, culture of the proverbs from time and again interspersed in the middle, give people to think and alert.

The more difficult part of this video is the API request data:

Method One (if post, applies only to one-dimensional arrays)

/**     * Curl Send HTPP Request     * can send Https,http,get way, post mode, post data send     *    /Public Function Datarequest ($url, $ Https=true, $method = ' get ', $data =null)    {        //Initialize curl        $ch = Curl_init ($url);        The string is not output directly, and a variable is stored        curl_setopt ($ch, Curlopt_returntransfer, 1);        HTTPS request        if ($https = = = True) {            //Ensure HTTPS request can request success            curl_setopt ($ch, curlopt_ssl_verifypeer,false);            curl_setopt ($ch, Curlopt_ssl_verifyhost,false);        }        Post request        if ($method = = ' Post ') {            curl_setopt ($ch, curlopt_post,true);            curl_setopt ($ch, Curlopt_postfields, $data);        }        Send request        $str = curl_exec ($ch);        $aStatus = Curl_getinfo ($ch);        Close connection        curl_close ($ch);        if (Intval ($aStatus ["http_code]) ==200) {            return Json_decode ($STR);        } else{            return false;        }    }

Method Two (if the Post method, for two-dimensional array)

/** * @Purpose: Curl sends HTPP request, can send Https,http,get way, post mode, post data send * @Author: Chrdai * @Method name:send                  Databycurl () * @parameter: string $url routed URL * Boolean $HTTPS use HTTPS * String $method Pass Method * Array $data data * @return: Returns the result returned successfully, False */function Senddat    Abycurl ($url, $https =true, $method = ' get ', $data =null) {//Initialize curl $ch = Curl_init ($url);    The string is not output directly, and a variable is stored curl_setopt ($ch, Curlopt_returntransfer, 1);        HTTPS request if ($https = = = True) {//Ensure HTTPS request can request success curl_setopt ($ch, Curlopt_ssl_verifypeer,false);    curl_setopt ($ch, Curlopt_ssl_verifyhost,false);        }//Post request if ($method = = ' Post ') {curl_setopt ($ch, curlopt_post,true);    The required array is processed with the http_bulid_query () function, and a two-dimensional array can be passed curl_setopt ($ch, Curlopt_postfields, Http_build_query ($data));    }//Send request $STR = curl_exec ($ch);    $aStatus = Curl_getinfo ($ch); Shut downConnection Curl_close ($ch);    if (Intval ($aStatus ["Http_code"]) ==200) {return json_decode ($STR);    }else{return false; }}

Method Three (if post, applies to pass JSON)

/** * @Purpose: Curl sends HTPP request, can send Https,http,get way, post mode, post data send * @Author: Chrdai * @Method name:send                  Databycurl () * @parameter: string $url routed URL * Boolean $HTTPS use HTTPS * String $method Pass Method * Array $jsonStr The JSON string to be passed * @return: Returns the result returned successfully, False */func    tion Senddatabycurl ($url, $https =true, $method = ' get ', $jsonStr =null) {//Initialize curl $ch = Curl_init ($url);    The string is not output directly, and a variable is stored curl_setopt ($ch, Curlopt_returntransfer, 1);        HTTPS request if ($https = = = True) {//Ensure HTTPS request can request success curl_setopt ($ch, Curlopt_ssl_verifypeer,false);    curl_setopt ($ch, Curlopt_ssl_verifyhost,false);        }//Post request if ($method = = ' Post ') {curl_setopt ($ch, curlopt_post,true);        curl_setopt ($ch, Curlopt_postfields, $JSONSTR);        Just use an HTTP header to pass the JSON! curl_setopt ($ch, Curlopt_httpheader, Array (' Content-type:application/json; chArset=utf-8 ', ' content-length: '.    Strlen ($JSONSTR)));    }//Send request $STR = curl_exec ($ch);    $aStatus = Curl_getinfo ($ch);    Close connection curl_close ($ch);    if (Intval ($aStatus ["Http_code"]) ==200) {return json_decode ($STR);    }else{return false; }}

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.