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. boby@sok-01:~$ php -m | grep curl curl boby@sok-01:~$ If php-curl module is not installed, you can install … Read more

CURL ERROR 7 could not establish a secure connection to WordPress.org

WordPress

On a WordPress website hosted on a CentOS server, I got the following error on the header of the website. Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. … Read more

curl using cookie

Here is some example of using curl to login to site, use cookie to do further requests. curl -k –cookie-jar ./cookies_hotfile –data “returnto=%2F&user=USERNAME_HERE&pass=PASSWORD_HERE” http://site.com/login.php curl -L -O –cookie ./cookies_hotfile http://site.com/dl/5222/4444/file.zip.html See curl

Fetch as Google with curl

A hacked web site got hacked. The site listed on google SERP with text “There are essentially two prescribed drugs which viagra 200mg”. When you visit the site in the browser and check the source, you see everything normal, no text related to Viagra. This is because malware on the site only shows that content … Read more

Check if HTTP/2 enabled using curl

To see if a web site have HTTP/2 enabled, you can run curl -sI SITE_URL_HERE -o /dev/null -w ‘%{http_version}\n’ If you see 2, the site have HTTP/2 enabled. Example boby@sok-01:~$ curl -sI https://serverok.in/ -o /dev/null -w ‘%{http_version}\n’ 2 boby@sok-01:~$ Here is a site with no HTTP/2 boby@sok-01:~$ curl -sI http://ok.serverok.in/ -o /dev/null -w ‘%{http_version}\n’ 1.1 … Read more

Making POST request from curl

Here is an example POST request using curl curl -d “param1=value1&param2=value2” -X POST http://sok.test/post.php Sending JSON string curl http://video.com/like -X POST –data ‘{“like”:”1″,”media_id”:”781″,”time_start”:”100:36:19.584″}’ Post a variable curl URL_HERE -X POST –data ‘badSSN=111111111’

Using Host Header in curl

When you have multiple websites hosted on a server, if you want to access one of the site using curl to IP of the server, then you need to pass the Host header value. For example If you want to show debug info, add –verbose Here is another way to do it Back to curl

curl

View Header To view the response header, use Specify Host Header Example Using Proxy To connect to a proxy using an Authenticated proxy, use Proxy with IP auth example To connect using Socks5 proxy running on 127.0.0.1 port 7070, run For socks proxy with authentication, use Sent Multiple Rquests Following command will sent 100 requet … Read more