美文网首页
php发送post 请求URL

php发送post 请求URL

作者: 刚_dbac | 来源:发表于2018-01-10 17:15 被阅读0次

    protected function http_request($url, $data = null)

    {

               $curl = curl_init();

               curl_setopt($curl, CURLOPT_URL, $url);

               curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

               curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);

               if (!empty($data)){

                      curl_setopt($curl, CURLOPT_POST, 1);

                      curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

                  }

                  curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

                   $output = curl_exec($curl);

                   curl_close($curl);

                   return $output;

    }

    相关文章

      网友评论

          本文标题:php发送post 请求URL

          本文链接:https://www.haomeiwen.com/subject/cbvonxtx.html