Skip to content

Commit 5d8bbb1

Browse files
committed
[JSONBridge] Add cookie param
1 parent 78b8b69 commit 5d8bbb1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bridges/JSONBridge.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ class JSONBridge extends BridgeAbstract {
1212
'name' => 'JSON URL',
1313
'type' => 'text',
1414
'required' => true,
15+
'exampleValue' => 'https://example.com/json/',
1516
'title' => 'The URL returning a JSON document (array or object)',
1617
],
18+
'cookie' => [
19+
'name' => 'The complete cookie value',
20+
'title' => 'Paste the cookie value from your browser if needed',
21+
'required' => false,
22+
],
1723
'root' => [
1824
'name' => 'JMESPath: items selector',
1925
'type' => 'text',
@@ -59,7 +65,13 @@ class JSONBridge extends BridgeAbstract {
5965
]];
6066

6167
public function collectData() {
62-
$raw = getContents($this->getInput('url'));
68+
if ($this->getInput('cookie')) {
69+
$raw = getContents($this->getInput('url'), [], [CURLOPT_COOKIE => $this->getInput('cookie')]);
70+
}
71+
else {
72+
$raw = getContents($this->getInput('url'));
73+
}
74+
6375
$json = json_decode($raw, true);
6476
if ($json === null) {
6577
returnServerError('Invalid JSON');

0 commit comments

Comments
 (0)