diff --git a/README.md b/README.md index 1b96869..5ad1832 100644 --- a/README.md +++ b/README.md @@ -41,19 +41,19 @@ require __DIR__ . '/vendor/autoload.php'; use \Curl\Curl; $curl = new Curl(); -$curl->get('http://www.example.com/'); +$curl->get('https://www.example.com/'); ``` ```php $curl = new Curl(); -$curl->get('http://www.example.com/search', array( +$curl->get('https://www.example.com/search', array( 'q' => 'keyword', )); ``` ```php $curl = new Curl(); -$curl->post('http://www.example.com/login/', array( +$curl->post('https://www.example.com/login/', array( 'username' => 'myusername', 'password' => 'mypassword', )); @@ -62,11 +62,11 @@ $curl->post('http://www.example.com/login/', array( ```php $curl = new Curl(); $curl->setBasicAuthentication('username', 'password'); -$curl->setUserAgent(''); +$curl->setUserAgent('MyUserAgent/0.0.1 (+https://www.example.com/bot.html)'); $curl->setReferrer(''); $curl->setHeader('X-Requested-With', 'XMLHttpRequest'); $curl->setCookie('key', 'value'); -$curl->get('http://www.example.com/'); +$curl->get('https://www.example.com/'); if ($curl->error) { echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage; @@ -87,7 +87,7 @@ $curl->get('https://encrypted.example.com/'); ```php $curl = new Curl(); -$curl->put('http://api.example.com/user/', array( +$curl->put('https://api.example.com/user/', array( 'first_name' => 'Zach', 'last_name' => 'Borboa', )); @@ -95,21 +95,21 @@ $curl->put('http://api.example.com/user/', array( ```php $curl = new Curl(); -$curl->patch('http://api.example.com/profile/', array( +$curl->patch('https://api.example.com/profile/', array( 'image' => '@path/to/file.jpg', )); ``` ```php $curl = new Curl(); -$curl->patch('http://api.example.com/profile/', array( +$curl->patch('https://api.example.com/profile/', array( 'image' => new CURLFile('path/to/file.jpg'), )); ``` ```php $curl = new Curl(); -$curl->delete('http://api.example.com/user/', array( +$curl->delete('https://api.example.com/user/', array( 'id' => '1234', )); ``` diff --git a/docs/README.md b/docs/README.md index a24965b..4d289cd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ # PHP Curl Class Documentation -http://www.phpcurlclass.com/ +https://www.phpcurlclass.com/ The [examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples) are a great starting point. diff --git a/examples/get.php b/examples/get.php index 2e41f87..f545059 100644 --- a/examples/get.php +++ b/examples/get.php @@ -4,9 +4,12 @@ require __DIR__ . '/vendor/autoload.php'; use \Curl\Curl; $curl = new Curl(); -for ($i = 1; $i <= 10; $i++) { - $curl->get('https://httpbin.org/get', array( - 'page' => $i, - )); - // TODO: Do something with result $curl->response. +$curl->get('https://httpbin.org/get'); + +if ($curl->error) { + echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage; +} +else { + echo 'Response:' . "\n"; + var_dump($curl->response); } diff --git a/examples/get_pages.php b/examples/get_pages.php new file mode 100644 index 0000000..2e41f87 --- /dev/null +++ b/examples/get_pages.php @@ -0,0 +1,12 @@ +get('https://httpbin.org/get', array( + 'page' => $i, + )); + // TODO: Do something with result $curl->response. +} diff --git a/examples/google_maps_geocode_address.php b/examples/google_maps_geocode_address.php index 52f0082..d712782 100644 --- a/examples/google_maps_geocode_address.php +++ b/examples/google_maps_geocode_address.php @@ -5,7 +5,7 @@ use \Curl\Curl; $address = 'Paris, France'; $curl = new Curl(); -$curl->get('http://maps.googleapis.com/maps/api/geocode/json', array( +$curl->get('https://maps.googleapis.com/maps/api/geocode/json', array( 'address' => $address, )); diff --git a/examples/post_redirect_get.php b/examples/post_redirect_get.php index 5b8d885..068245c 100644 --- a/examples/post_redirect_get.php +++ b/examples/post_redirect_get.php @@ -3,7 +3,7 @@ // using GET requests). $curl = new Curl(); $curl->setOpt(CURLOPT_FOLLOWLOCATION, true); -$curl->post('http://www.example.com/login/', array( +$curl->post('https://www.example.com/login/', array( 'username' => 'myusername', 'password' => 'mypassword', )); @@ -13,7 +13,7 @@ $curl->post('http://www.example.com/login/', array( // 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( +$curl->post('https://www.example.com/login/', array( 'username' => 'myusername', 'password' => 'mypassword', ), false); diff --git a/examples/reddit_top_pics.php b/examples/reddit_top_pics.php index 4ecaade..db994c4 100644 --- a/examples/reddit_top_pics.php +++ b/examples/reddit_top_pics.php @@ -9,7 +9,7 @@ if (isset($_GET['after'])) { } $curl = new Curl(); -$curl->get('http://www.reddit.com/r/pics/top/.json', $data); +$curl->get('https://www.reddit.com/r/pics/top/.json', $data); echo '