Make a HTTPS request through PHP and get response

后端 未结 4 861
青春惊慌失措
青春惊慌失措 2020-12-01 16:50

I want to make HTTPS request through PHP to a server and get the response.

something similar to this ruby code

  http = Net::HTTP.new(\"www.example.c         


        
4条回答
  •  鱼传尺愫
    2020-12-01 17:23

    The Zend Framework has a nice component called Zend_Http_Client which is perfect for this kind of transaction.

    Under the hood it uses curl to make requests, but you'll find Zend_Http_Client has a much nicer interface to work with and is easier to configure when you want to add custom headers or work with responses.

    If all you want to do is retrieve the page contents with minimal work, you may be able to do the following, depending on your server's configuration:

    $data = file_get_contents('https://www.example.com/');
    

提交回复
热议问题