From cd19c3bd2ddc63da3650d944b27d03f0dafc1c71 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sun, 7 Aug 2016 15:29:21 -0700 Subject: [PATCH] Simplify get example --- examples/get.php | 13 ++++++++----- examples/get_pages.php | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 examples/get_pages.php 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. +}