Browsing articles tagged with

curl

Download a file using curl in php

Here is a quick curl snippet for php, that can download a remote file and save it. <?php set_time_limit(0); //File to save the contents to $fp = fopen ('files2.tar', 'w+'); $url = "http://localhost/files.tar"; //Here is the file we are downloading, replace spaces with %20 $ch = curl_init(str_replace(" ","%20",$url)); curl_setopt($ch, CURLOPT_TIMEOUT, 50); //give curl the file pointer so that it can write to it curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch);//get ...

How to use proxy with curl in php

Proxy with Curl Curl is a very useful library for transferring data over various protocols like http, ftp, https etc. In other words curl can be used to programatically download a web page, or upload file to ftp etc. It also supports using a proxy. This means that curl requests can go through a proxy server just like a web browser ...

Php curl tutorial – making http requests in php

Curl According to the official website. curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, ...

Use clientside ssl certificate with curl and php

Clientside certificates are often used in soap webservices. For example the wsdl file link might require a clientside certificate. The server throws an error like this : HTTP Error 403.7 - Forbidden: SSL client certificate is required. Curl Command To use clientside certificate with curl , test the following command curl --cert certificate_file.pem https://www.example.com/some_protected_page or curl --cert certificate_file.pem:password https://www.example.com/some_protected_page The above command should fetch the protected page ...

Remote Login with Curl PHP

Remote login with CURL The curl extension of php can be used to open remote webpages by both GET and POST methods. There are many situations when you need a php script to login into a website and open a certain page. For example when you are writing a bot or web scraper. To login we need 2 important piece of information ...



Connect with us