-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 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
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,24 @@ | ||
<?php | ||
|
||
// First, include the Composer Autoloader. | ||
require_once dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
||
// Next, create the HTTP client | ||
$client = new \Art4\Requests\Psr\HttpClient(); | ||
|
||
// Next, create the HTTP request | ||
$request = $client->createRequest(\WpOrg\Requests\Requests::POST, 'http://httpbin.org/post'); | ||
|
||
// You can set headers in PSR-7 style | ||
$request = $request->withAddedHeader('Accept', 'application/json'); | ||
|
||
// You can set form data as body | ||
$request = $request->withBody($client->createStream( | ||
http_build_query(['mydata' => 'something']) | ||
)); | ||
|
||
// Now let's make a request! | ||
$response = $client->sendRequest($request); | ||
|
||
// Check what we received | ||
var_dump($response); |
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