-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexample.php
More file actions
37 lines (28 loc) · 830 Bytes
/
example.php
File metadata and controls
37 lines (28 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require "vendor/autoload.php";
use Resty\Resty;
$resty = new Resty();
$resty->setBaseURL('http://httpbin.org/');
$resp = $resty->get('headers');
echo "\n\$resp['status']:\n";
var_dump($resp['status']);
echo "\n\$resp['headers']:\n";
var_dump($resp['headers']);
echo "\n\$resp['body']:\n";
var_dump($resp['body']);
echo "\n\$resp['body_raw']:\n";
var_dump($resp['body_raw']);
/**
* Resty::postJson() encodes the object or array as JSON and sends it as
* the request body.
*/
$to_json = array(
"foo"=>array(
"bar"=>"baz",
"bee"=>"bim",
"bop"=>23
)
);
$resp = $resty->postJson('post', $to_json);
echo "\n\$resp['body']->json:\n";
var_dump($resp['body']->json);