blob: e5dcf268f81bfb5da755373939d4ff240ba87e89 (
plain)
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
|
<?php
/**
* PCurl is a REST client libary for PHP.
*
* See http://github.com/purplecode/php.curl for details.
*
* This code is licensed for use, modification, and distribution
* under the terms of the MIT License (see http://en.wikipedia.org/wiki/MIT_License)
*/
namespace PurpleCode\PCurl;
class PJsonCurl extends PCurl {
private $arrayResponse;
public function __construct($host) {
parent::__construct($host);
$this->arrayResponse = false;
$this->contentTypeJson();
}
public function call($method, $url, $payload = '') {
$payload = json_encode($payload);
$response = parent::call($method, $url, $payload);
return json_decode($response, $this->arrayResponse);
}
public function arrayResponse($arrayResponse = true) {
$this->arrayResponse = $arrayResponse;
}
}
|