* [curl_post curl post方式请求接口]
     * @param  [type] $url  [接口的url]
     * @param  [type] $data [传递的参数]
     * @return [type]       [返回接口信息]
     */
    private function curl_post($url, $data) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $return = curl_exec($ch);
        $status = curl_getinfo($ch);
        curl_close($ch);
        if(intval($status["http_code"]) == 200) {
            return $return;
        } else {
            echo $status["http_code"];
            return false;
        }
    }

 

posted on 2017-01-03 22:26  晨曦年华  阅读(1780)  评论(0编辑  收藏  举报