mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-10-18 18:07:41 +00:00
Move post/redirect/get example to examples
This commit is contained in:
@@ -53,28 +53,8 @@ $curl->post('http://www.example.com/login/', array(
|
||||
'username' => 'myusername',
|
||||
'password' => 'mypassword',
|
||||
));
|
||||
|
||||
// Perform a post-redirect-get request (POST data and follow 303 redirections using GET requests).
|
||||
$curl = new Curl();
|
||||
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);¬
|
||||
$curl->post('http://www.example.com/login/', array(
|
||||
'username' => 'myusername',
|
||||
'password' => 'mypassword',
|
||||
));
|
||||
|
||||
// POST data and follow 303 redirections by POSTing data again.
|
||||
// Please note that 303 redirections should not be handled this way:
|
||||
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
|
||||
$curl = new Curl();
|
||||
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);¬
|
||||
$curl->post('http://www.example.com/login/', array(
|
||||
'username' => 'myusername',
|
||||
'password' => 'mypassword',
|
||||
), false);
|
||||
```
|
||||
|
||||
A POST request performs by default a post-redirect-get (see above). Other request methods force an option which conflicts with the post-redirect-get behavior. Due to technical limitations of PHP engines <5.5.11 and HHVM, it is not possible to reset this option. It is therefore impossible to perform a post-redirect-get request using a php-curl-class Curl object that has already been used to perform other types of requests. Either use a new php-curl-class Curl object or upgrade your PHP engine.
|
||||
|
||||
```php
|
||||
$curl = new Curl();
|
||||
$curl->setBasicAuthentication('username', 'password');
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// Perform a post-redirect-get request (POST data and follow 303 redirections
|
||||
// using GET requests).
|
||||
$curl = new Curl();
|
||||
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
|
||||
$curl->post('http://www.example.com/login/', array(
|
||||
'username' => 'myusername',
|
||||
'password' => 'mypassword',
|
||||
));
|
||||
|
||||
// POST data and follow 303 redirections by POSTing data again. Please note
|
||||
// that 303 redirections should not be handled this way.
|
||||
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
|
||||
$curl = new Curl();
|
||||
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
|
||||
$curl->post('http://www.example.com/login/', array(
|
||||
'username' => 'myusername',
|
||||
'password' => 'mypassword',
|
||||
), false);
|
||||
|
||||
// A POST request performs a post-redirect-get by default. Other request
|
||||
// methods force an option which conflicts with the post-redirect-get behavior.
|
||||
// Due to technical limitations of PHP engines <5.5.11 and HHVM, it is not
|
||||
// possible to reset this option. It is therefore impossible to perform a
|
||||
// post-redirect-get request using a php-curl-class Curl object that has already
|
||||
// been used to perform other types of requests. Either use a new php-curl-class
|
||||
// Curl object or upgrade your PHP engine.
|
||||
Reference in New Issue
Block a user