Skip to content

Commit 142ba93

Browse files
author
Openset
committed
Add: json
1 parent 032ee41 commit 142ba93

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/HttpClient.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ public static function post($url, array $options = [])
7272
return self::request('POST', $url, [$key => $options]);
7373
}
7474

75+
/**
76+
* @param $url
77+
* @param string $options
78+
* @param array $queries
79+
* @param int $encodeOption
80+
* @return bool|\Psr\Http\Message\StreamInterface
81+
* @throws \GuzzleHttp\Exception\GuzzleException
82+
*/
83+
public function json($url, $options = '{}', array $queries = [], $encodeOption = JSON_UNESCAPED_UNICODE)
84+
{
85+
is_array($options) && $options = json_encode($options, $encodeOption);
86+
87+
return self::request('POST', $url, [
88+
'query' => $queries,
89+
'body' => $options,
90+
'headers' => [
91+
'content-type' => 'application/json'
92+
],
93+
]);
94+
}
95+
7596
/**
7697
* @param $method
7798
* @param array $args

0 commit comments

Comments
 (0)