Home  >  Article  >  Backend Development  >  Send https request using php

Send https request using php

不言
不言Original
2018-04-14 12:01:154415browse

This article mainly introduces using php to send https requests. It has certain reference value. Now I share it with everyone. Friends in need can refer to it

I will use it recently, so I wrote a program to test it. Use php to send an https request and run it directly in http://www.dooccn.com/php7/:

<?php

	function curl_get_https($url)
	{
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_HEADER, 0);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  // 跳过检查
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);  // 跳过检查
		$tmpInfo = curl_exec($curl); 
		curl_close($curl);
		return $tmpInfo;   //返回json对象
	}


    $url = "https://www.baidu.com";
    // $url = "https://115.159.119.33"; 
    
	$result = curl_get_https($url);
	
    
    var_dump($result);
?>

The result is OK

Related recommendations:

PHP publishes WebService instance sharing

php sends data to kafka implementation code


The above is the detailed content of Send https request using php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php capture picturesNext article:php capture pictures