Home > Backend Development > PHP Tutorial > Send https request using php

Send https request using php

不言
Release: 2023-03-23 20:12:01
Original
4530 people have browsed it

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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
***Enable https service
From 1970-01-01 08:00:00
0
0
0
Nginx HTTP redirect to HTTPS
From 1970-01-01 08:00:00
0
0
0
phpstudy novice tutorial https configuration
From 1970-01-01 08:00:00
0
0
0
Problem with using https in phpstudy
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template