|
@@ -20,6 +20,9 @@ Pull this package in through Composer.
|
|
|
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+or run in terminal:
|
|
|
|
+`composer require ixudra/curl`
|
|
|
|
+
|
|
|
|
|
|
### Laravel 5.* Integration
|
|
### Laravel 5.* Integration
|
|
|
|
|
|
@@ -140,22 +143,28 @@ method.
|
|
In order to send a `GET` request, you need to use the `get()` method that is provided by the package:
|
|
In order to send a `GET` request, you need to use the `get()` method that is provided by the package:
|
|
|
|
|
|
```php
|
|
```php
|
|
|
|
+use Ixudra\Curl\Facades\Curl;
|
|
|
|
|
|
- // Send a GET request to: http://www.foo.com/bar
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
- ->get();
|
|
|
|
-
|
|
|
|
- // Send a GET request to: http://www.foo.com/bar?foz=baz
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
- ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
- ->get();
|
|
|
|
|
|
+class Foo
|
|
|
|
+{
|
|
|
|
+ public function bar ()
|
|
|
|
+ {
|
|
|
|
+ // Send a GET request to: http://www.foo.com/bar
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
+ ->get();
|
|
|
|
|
|
- // Send a GET request to: http://www.foo.com/bar?foz=baz using JSON
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
- ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
- ->asJson()
|
|
|
|
- ->get();
|
|
|
|
|
|
+ // Send a GET request to: http://www.foo.com/bar?foz=baz
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
+ ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
+ ->get();
|
|
|
|
|
|
|
|
+ // Send a GET request to: http://www.foo.com/bar?foz=baz using JSON
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar')
|
|
|
|
+ ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
+ ->asJson()
|
|
|
|
+ ->get();
|
|
|
|
+ }
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
@@ -169,7 +178,7 @@ use Ixudra\Curl\Facades\Curl;
|
|
class Foo
|
|
class Foo
|
|
{
|
|
{
|
|
public function bar ()
|
|
public function bar ()
|
|
- {
|
|
|
|
|
|
+ {
|
|
// Send a POST request to: http://www.foo.com/bar
|
|
// Send a POST request to: http://www.foo.com/bar
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
->post();
|
|
->post();
|
|
@@ -190,9 +199,8 @@ class Foo
|
|
->withData( array( 'foz' => 'baz' ) )
|
|
->withData( array( 'foz' => 'baz' ) )
|
|
->asJson( true )
|
|
->asJson( true )
|
|
->post();
|
|
->post();
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
@@ -201,13 +209,19 @@ class Foo
|
|
Put requests work similar to `POST` requests, but use the `put()` method instead:
|
|
Put requests work similar to `POST` requests, but use the `put()` method instead:
|
|
|
|
|
|
```php
|
|
```php
|
|
|
|
+use Ixudra\Curl\Facades\Curl;
|
|
|
|
|
|
- // Send a PUT request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
- ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
- ->asJson()
|
|
|
|
- ->put();
|
|
|
|
-
|
|
|
|
|
|
+class Foo
|
|
|
|
+{
|
|
|
|
+ public function bar ()
|
|
|
|
+ {
|
|
|
|
+ // Send a PUT request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
+ ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
+ ->asJson()
|
|
|
|
+ ->put();
|
|
|
|
+ }
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
@@ -216,13 +230,19 @@ Put requests work similar to `POST` requests, but use the `put()` method instead
|
|
Patch requests work similar to `POST` requests, but use the `patch()` method instead:
|
|
Patch requests work similar to `POST` requests, but use the `patch()` method instead:
|
|
|
|
|
|
```php
|
|
```php
|
|
|
|
+use Ixudra\Curl\Facades\Curl;
|
|
|
|
|
|
- // Send a PATCH request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
- ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
- ->asJson()
|
|
|
|
- ->patch();
|
|
|
|
-
|
|
|
|
|
|
+class Foo
|
|
|
|
+{
|
|
|
|
+ public function bar ()
|
|
|
|
+ {
|
|
|
|
+ // Send a PATCH request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
+ ->withData( array( 'foz' => 'baz' ) )
|
|
|
|
+ ->asJson()
|
|
|
|
+ ->patch();
|
|
|
|
+ }
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
@@ -231,12 +251,18 @@ Patch requests work similar to `POST` requests, but use the `patch()` method ins
|
|
Delete requests work similar to `GET` requests, but use the `delete()` method instead:
|
|
Delete requests work similar to `GET` requests, but use the `delete()` method instead:
|
|
|
|
|
|
```php
|
|
```php
|
|
|
|
+use Ixudra\Curl\Facades\Curl;
|
|
|
|
|
|
- // Send a DELETE request to: http://www.foo.com/bar/1 using JSON
|
|
|
|
- $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
- ->asJson()
|
|
|
|
- ->delete();
|
|
|
|
-
|
|
|
|
|
|
+class Foo
|
|
|
|
+{
|
|
|
|
+ public function bar ()
|
|
|
|
+ {
|
|
|
|
+ // Send a DELETE request to: http://www.foo.com/bar/1 using JSON
|
|
|
|
+ $response = Curl::to('http://www.foo.com/bar/1')
|
|
|
|
+ ->asJson()
|
|
|
|
+ ->delete();
|
|
|
|
+ }
|
|
|
|
+}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|