This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/29' into develop
Forward port #29
- Loading branch information
Showing
8 changed files
with
2,944 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# HTTP Client - Static Usage | ||
|
||
## Overview | ||
|
||
The `Zend\Http` component also provides `Zend\Http\ClientStatic`, a static HTTP client which exposes | ||
a simplified API for quickly performing GET and POST operations: | ||
|
||
## Quick Start | ||
|
||
```php | ||
use Zend\Http\ClientStatic; | ||
|
||
// Simple GET request | ||
$response = ClientStatic::get('http://example.org'); | ||
|
||
// More complex GET request, specifying query string 'foo=bar' and adding a | ||
// custom header to request JSON data be returned (Accept: application/json) | ||
$response = ClientStatic::get( | ||
'http://example.org', | ||
array('foo' => 'bar'), | ||
array('Accept' => 'application/json') | ||
); | ||
|
||
// We can also do a POST request using the same format. Here we POST | ||
// login credentials (username/password) to a login page: | ||
$response = ClientStatic::post('https://example.org/login.php', array( | ||
'username' => 'foo', | ||
'password' => 'bar', | ||
)); | ||
``` | ||
|
||
## Available Methods | ||
|
||
**get** | ||
`get(string $url, array $query = array(), array $headers = array(), mixed $body = null, | ||
$clientOptions = null)` | ||
|
||
Perform an HTTP `GET` request using the provided URL, query string variables, headers and request | ||
body. The fifth parameter can be used to pass configuration options to the HTTP Client instance. | ||
|
||
Returns Zend\\Http\\Response | ||
|
||
<!-- --> | ||
|
||
**post** | ||
`post(string $url, array $params, array $headers = array(), mixed $body = null, $clientOptions = | ||
null)` | ||
|
||
Perform an HTTP `POST` request using the provided URL, parameters, headers and request body. The | ||
fifth parameter can be used to pass configuration options to the HTTP Client instance. | ||
|
||
Returns Zend\\Http\\Response | ||
|
||
|
Oops, something went wrong.