Skip to content

Commit b960160

Browse files
committed
Version 2.0
2 parents 561256d + eba0839 commit b960160

5 files changed

Lines changed: 304 additions & 61 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# (MODX)EvolutionCMS.snippets.ddMakeHttpRequest changelog
2+
3+
4+
## Version 2.0 (2019-09-23)
5+
* \* **Attention!** Backward compatibility is broken. If you want send raw JSON in `postData` you must set `sendRawPostData` equal to `1`.
6+
* \+ `postData` can be set as a JSON object.
7+
* \+ `headers` can be set as a JSON array.
8+
* \+ Added an ability to send raw `postData` (see `sendRawPostData`).
9+
10+
11+
## Version 1.0 (2011-06-16)
12+
* \+ The first release.
13+
14+
15+
<style>ul{list-style:none;}</style>

CHANGELOG_ru.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# (MODX)EvolutionCMS.snippets.ddMakeHttpRequest changelog
2+
3+
4+
## Version 2.0 (2019-09-23)
5+
* \* **Внимание!** Обратная совместимость нарушена. Если вы хотите отправить сырой JSON в `postData`, выставьте параметр `sendRawPostData` в `1`.
6+
* \+ Параметр `postData` может быть задан, как JSON-объект.
7+
* \+ Параметр `headers` может быть задан, как JSON-массив.
8+
* \+ Параметр `sendRawPostData`.
9+
10+
11+
## Version 1.0 (2011-06-16)
12+
* \+ Первый релиз.
13+
14+
15+
<style>ul{list-style:none;}</style>

README.md

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,127 @@
11
# (MODX)EvolutionCMS.snippets.ddMakeHttpRequest
22

33
Makes HTTP request to a given URL.
4-
___
5-
Visit the following [link](http://code.divandesign.biz/modx/ddmakehttprequest) to read the documentation, instructions & changelog.
4+
5+
6+
## # Requires
7+
* PHP >= 5.4
8+
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.23
9+
10+
11+
## # Documentation
12+
13+
14+
### ## Installation
15+
Elements → Snippets: Create a new snippet with the following data:
16+
17+
1. Snippet name: `ddMakeHttpRequest`.
18+
2. Description: `<b>2.0</b> Makes HTTP request to a given URL.`.
19+
3. Category: `Core`.
20+
4. Parse DocBlock: `no`.
21+
5. Snippet code (php): Insert content of the `ddMakeHttpRequest_snippet` file from the archive.
22+
23+
24+
### ## Parameters description
25+
26+
* `url`
27+
* Desctription: The URL to fetch.
28+
* Valid values: `string`
29+
* **Required**
30+
31+
* `method`
32+
* Desctription: Request type.
33+
* Valid values:
34+
* `'get'`
35+
* `'post'`
36+
* Default value: `'get'`
37+
38+
* `postData`
39+
* Desctription: The full data to post in a HTTP “POST” operation.
40+
* Valid values:
41+
* `string_json` — as [JSON](https://en.wikipedia.org/wiki/JSON) object
42+
* `string_queryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
43+
* `array_associative`
44+
* `string`
45+
* Default value: —
46+
47+
* `sendRawPostData`
48+
* Desctription: Send raw `postData`. E. g. if you need JSON in request payload.
49+
* Valid values:
50+
* `0`
51+
* `1`
52+
* Default value: `0`
53+
54+
* `headers`
55+
* Desctription: An array of HTTP header fields to set.
56+
* Valid values:
57+
* `string_json` — as [JSON](https://en.wikipedia.org/wiki/JSON) object
58+
* `string_queryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
59+
* `array`
60+
* Default value: —
61+
62+
* `userAgent`
63+
* Desctription: The contents of the `User-Agent: ` header to be used in a HTTP request.
64+
* Valid values: `string`
65+
* Default value: —
66+
67+
* `timeout`
68+
* Desctription: The maximum number of seconds for execute request.
69+
* Valid values: `integer`
70+
* Default value: `60`
71+
72+
* `proxy`
73+
* Desctription: Proxy server in format `[+protocol+]://[+user+]:[+password+]@[+ip+]:[+port+]`. E. g. `http://asan:gd324ukl@11.22.33.44:5555` or `socks5://asan:gd324ukl@11.22.33.44:5555`.
74+
* Valid values: `string`
75+
* Default value: —
76+
77+
78+
### ## Examples
79+
80+
81+
#### ### Simple GET request
82+
```
83+
[[ddMakeHttpRequest? &url=`http://www.example.com?name=John&surname=Doe`]]
84+
```
85+
86+
87+
#### ### Simple POST request
88+
Set data as JSON
89+
```
90+
[[ddMakeHttpRequest?
91+
&url=`http://www.example.com/`
92+
&postData=`{
93+
"name": "John",
94+
"surname": "Doe"
95+
}`
96+
]]
97+
```
98+
Or Query string
99+
```
100+
[[ddMakeHttpRequest?
101+
&url=`http://www.example.com/`
102+
&postData=`name=John&surname=Doe`
103+
]]
104+
```
105+
106+
107+
#### ### CMS API
108+
```php
109+
$requestResult = $modx->runSnippet(
110+
'ddMakeHttpRequest',
111+
[
112+
'url' => 'https://www.example.com/',
113+
'postData' => [
114+
'name' => 'John',
115+
'surname' => 'Doe'
116+
],
117+
'headers' => [
118+
'Accept: application/vnd.api+json',
119+
'Content-Type: application/vnd.api+json'
120+
],
121+
'proxy' => 'socks5://asan:gd324ukl@11.22.33.44:5555'
122+
]
123+
);
124+
```
125+
126+
127+
## # [Home page →](https://code.divandesign.biz/modx/ddmakehttprequest)

README_ru.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# (MODX)EvolutionCMS.snippets.ddMakeHttpRequest
2+
3+
Отправляет HTTP запрос к заданному URL.
4+
5+
6+
## # Requires
7+
* PHP >= 5.4
8+
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.23
9+
10+
11+
## # Документация
12+
13+
14+
### ## Установка
15+
Элементы → Сниппеты: Создать новый сниппет со следующими параметрами:
16+
17+
1. Название сниппета: `ddMakeHttpRequest`.
18+
2. Описание: `<b>2.0</b> Makes HTTP request to a given URL.`.
19+
3. Категория: `Core`.
20+
4. Анализировать DocBlock: `no`.
21+
5. Код сниппета (php): Вставьте содержимое файла `ddMakeHttpRequest_snippet` из архива.
22+
23+
24+
### ## Описание параметров
25+
26+
* `url`
27+
* Описание: Адрес, к которому обращаться.
28+
* Допустимые значения: `string`
29+
* **Обязателен**
30+
31+
* `method`
32+
* Описание: Тип запроса.
33+
* Допустимые значения:
34+
* `'get'`
35+
* `'post'`
36+
* Значение по умолчанию: `'get'`
37+
38+
* `postData`
39+
* Описание: Данные, которые нужно отправить.
40+
* Допустимые значения:
41+
* `string_json` — в виде [JSON](https://en.wikipedia.org/wiki/JSON) object
42+
* `string_queryFormated` — в виде [Query string](https://en.wikipedia.org/wiki/Query_string)
43+
* `array_associative`
44+
* `string`
45+
* Значение по умолчанию: —
46+
47+
* `sendRawPostData`
48+
* Описание: Отправить `postData` в сыром виде. Например, если нужен JSON in request payload.
49+
* Допустимые значения:
50+
* `0`
51+
* `1`
52+
* Значение по умолчанию: `0`
53+
54+
* `headers`
55+
* Описание: Заголовки, которые нужно отправить.
56+
* Допустимые значения:
57+
* `string_json` — в виде [JSON](https://en.wikipedia.org/wiki/JSON) object
58+
* `string_queryFormated` — в виде [Query string](https://en.wikipedia.org/wiki/Query_string)
59+
* `array`
60+
* Значение по умолчанию: —
61+
62+
* `userAgent`
63+
* Описание: Значение HTTP заголовка `User-Agent: `.
64+
* Допустимые значения: `string`
65+
* Значение по умолчанию: —
66+
67+
* `timeout`
68+
* Описание: Максимальное время выполнения запроса в секундах.
69+
* Допустимые значения: `integer`
70+
* Значение по умолчанию: `60`
71+
72+
* `proxy`
73+
* Описание: Прокси сервер в формате `[+protocol+]://[+user+]:[+password+]@[+ip+]:[+port+]`. Пример: `http://asan:gd324ukl@11.22.33.44:5555`, `socks5://asan:gd324ukl@11.22.33.44:5555`.
74+
* Допустимые значения: `string`
75+
* Значение по умолчанию: —
76+
77+
78+
### ## Примеры
79+
80+
81+
#### ### Простой GET-запрос
82+
```
83+
[[ddMakeHttpRequest? &url=`http://www.example.com?name=John&surname=Doe`]]
84+
```
85+
86+
87+
#### ### Простой POST-запрос
88+
Передаваемые данные мождно задать в виде JSON
89+
```
90+
[[ddMakeHttpRequest?
91+
&url=`http://www.example.com/`
92+
&postData=`{
93+
"name": "John",
94+
"surname": "Doe"
95+
}`
96+
]]
97+
```
98+
Или в виде Query string
99+
```
100+
[[ddMakeHttpRequest?
101+
&url=`http://www.example.com/`
102+
&postData=`name=John&surname=Doe`
103+
]]
104+
```
105+
106+
107+
#### ### CMS API
108+
```php
109+
$requestResult = $modx->runSnippet(
110+
'ddMakeHttpRequest',
111+
[
112+
'url' => 'https://www.example.com/',
113+
'postData' => [
114+
'name' => 'John',
115+
'surname' => 'Doe'
116+
],
117+
'headers' => [
118+
'Accept: application/vnd.api+json',
119+
'Content-Type: application/vnd.api+json'
120+
],
121+
'proxy' => 'socks5://asan:gd324ukl@11.22.33.44:5555'
122+
]
123+
);
124+
```
125+
126+
127+
## # [Home page →](https://code.divandesign.ru/modx/ddmakehttprequest)

0 commit comments

Comments
 (0)