PHP – CURL Authentication

MacBook avec code sur un bureau

To authenticate a cURL request in PHP, the option to know is CURLOPT_USERPWD. It sends a username / password pair in the user:password format. Basic authentication $ch = curl_init(‘https://example.com/api’); curl_setopt($ch, CURLOPT_USERPWD, ‘user:password’); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $response = curl_exec($ch); if ($response === false) { throw new RuntimeException(curl_error($ch)); } curl_close($ch); Setting … Read more

Categories PHP

jQuery file Upload – Basic solution with a callback

MacBook avec code sur un bureau

jQuery-File-Upload How to use the basic solution from http://blueimp.github.com/jQuery-File-Upload/ and make it work for all browsers (special dedication to Internet Explorer). The basic version has the advantage of not being overloaded with libraries and above all is much easier to import into an already-created website. Libraries Setting up To begin with, go to the address … Read more

Categories 431