How to get Contents of a Webpage using PHP curl

PHP cURL module allows you to connect to remote websites and API endpoints to exchange data. To see if you have php-curl enabled, you can check phpinfo() page or run the command “php -m’ and look for curl.

If php-curl module is not installed, you can install it on Ubuntu/Debian with the command

To access the content of a remote web server or API endpoint, you can use the following PHP code.

To make script work with invalid or self signed SSL, add following

If you want to make a POST request, you can use the following code

Back to PHP

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *