Если в пресете используется несколько парсеров, и попробовать добавить задание методом addTask, используя полученный из Shop Api query JSON то задание не добавляется и возвращает Null В качестве примера использовался этот пресет Спойлер: Пример <?php $json = '{ "password": "", "action": "addTask", "data": { "preset": "Check positions Table", "configPreset": "default", "parsers": [ [ "SE::Google:osition", "TOP 100", { "type": "override", "id": "gl", "value": "RU" } ], [ "SE::Yandex:osition", "TOP 100", { "type": "override", "id": "lr", "value": "225" } ], [ "SE::Google:osition", "TOP 100", { "type": "override", "id": "gl", "value": "UA" } ], [ "SE::Yandex:osition", "TOP 100", { "type": "override", "id": "lr", "value": "187" } ] ], "resultsFormat": "[% p1backcol = \'\';\np2backcol = \'\';\np3backcol = \'\';\np4backcol = \'\';\nIF p1.position == 0;\n p1backcol = \'danger\';\nEND;\nIF p1.position > 0 && p1.position <= 10;\n p1backcol = \'success\';\nEND;\nIF p1.position > 50;\n p1backcol = \'warning\';\nEND;\nIF p2.position == 0;\n p2backcol = \'danger\';\nEND;\nIF p2.position > 0 && p2.position <= 10;\n p2backcol = \'success\';\nEND;\nIF p2.position > 50;\n p2backcol = \'warning\';\nEND;\nIF p3.position == 0;\n p3backcol = \'danger\';\nEND;\nIF p3.position > 0 && p1.position <= 10;\n p3backcol = \'success\';\nEND;\nIF p3.position > 50;\n p3backcol = \'warning\';\nEND;\nIF p4.position == 0;\n p4backcol = \'danger\';\nEND;\nIF p4.position > 0 && p2.position <= 10;\n p4backcol = \'success\';\nEND;\nIF p4.position > 50;\n p4backcol = \'warning\';\nEND -%]\n<tr>\n<td>$p1.domain</td>\n<td>$p1.key</td>\n<td class=\"$p1backcol\">$p1.position</td>\n<td class=\"$p2backcol\">$p2.position</td>\n<td class=\"$p3backcol\">$p3.position</td>\n<td class=\"$p4backcol\">$p4.position</td>\n</tr>", "resultsSaveTo": "file", "resultsFileName": "$datefile.format().html", "additionalFormats": [], "resultsUnique": "no", "queriesFrom": "text", "queryFormat": [ "{subs:test-sites} $query" ], "uniqueQueries": false, "saveFailedQueries": false, "iteratorOptions": { "onAllLevels": false, "queryBuildersAfterIterator": false, "queryBuildersOnAllLevels": false }, "resultsOptions": { "overwrite": false }, "doLog": "no", "keepUnique": "No", "moreOptions": true, "resultsPrepend": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <title>Оценка позиций сайтов</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\">\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.css\">\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table-all.min.js\"></script>\n</head>\n<body>\n<div class=\"container\">\n <h2>Позиции</h2>\n <p>Таблица позиций сайтов в поисковой выдаче по указанным ключевым словам</p> \n <table class=\"table table-bordered\" data-sort-name=\"domain\" data-sort-order=\"asc\" data-toggle=\"table\">\n <thead>\n <tr>\n <th data-field=\"domain\" data-align=\"left\" data-sortable=\"true\">Домен</th>\n <th data-field=\"key\" data-align=\"left\" data-sortable=\"true\">Ключевое слово</th>\n <th data-field=\"google1\" data-align=\"center\" data-sortable=\"true\">Google<br>Россия</th>\n <th data-field=\"yandex1\" data-align=\"center\" data-sortable=\"true\">Yandex<br>Россия</th>\n <th data-field=\"google2\" data-align=\"center\" data-sortable=\"true\">Google<br>Украина</th>\n <th data-field=\"yandex2\" data-align=\"center\" data-sortable=\"true\">Yandex<br>Украина</th>\n </tr>\n </thead>\n <tbody>\n ", "resultsAppend": "\n</tbody>\n</table>\n<p align=\"right\"><font face=\"monospace\" size=\"2\" colo=\"silver\"><i>Parsed by <a href=\"http://a-parser.com/\">A-Parser</a>.</i></font></p> \n</div>\n</body>\n</html>", "queryBuilders": [], "resultsBuilders": [], "configOverrides": [], "runTaskOnComplete": null, "useResultsFileAsQueriesFile": false, "runTaskOnCompleteConfig": "default", "toolsJS": "", "prio": 5, "queries": "" } }'; $ch = curl_init('http://127.0.0.1:9091/API'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($json))); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain; charset=UTF-8')); $response = curl_exec($ch); curl_close($ch); $response = json_decode($response, true); var_dump($response['data']);
проблема совсем не в парсере, а в некорректном JSON, достаточно добавить Код: var_dump(json_decode($json)); и увидеть что в результате будет NULL, все дело в том что нельзя просто так скопировать JSON и вставить как PHP строку, необходимо использовать heredoc синтаксис с одинарными кавычками, в этом случае JSON не будет ломаться и задание успешно добавиться: Спойлер Код: $json = <<<'JSON' { "password": "123", "action": "addTask", "data": { "preset": "Check positions Table", "configPreset": "default", "parsers": [ [ "SE::Google::Position", "TOP 100", { "type": "override", "id": "gl", "value": "RU" } ], [ "SE::Yandex::Position", "TOP 100", { "type": "override", "id": "lr", "value": "225" } ], [ "SE::Google::Position", "TOP 100", { "type": "override", "id": "gl", "value": "UA" } ], [ "SE::Yandex::Position", "TOP 100", { "type": "override", "id": "lr", "value": "187" } ] ], "resultsFormat": "[% p1backcol = '';\np2backcol = '';\np3backcol = '';\np4backcol = '';\nIF p1.position == 0;\n p1backcol = 'danger';\nEND;\nIF p1.position > 0 && p1.position <= 10;\n p1backcol = 'success';\nEND;\nIF p1.position > 50;\n p1backcol = 'warning';\nEND;\nIF p2.position == 0;\n p2backcol = 'danger';\nEND;\nIF p2.position > 0 && p2.position <= 10;\n p2backcol = 'success';\nEND;\nIF p2.position > 50;\n p2backcol = 'warning';\nEND;\nIF p3.position == 0;\n p3backcol = 'danger';\nEND;\nIF p3.position > 0 && p1.position <= 10;\n p3backcol = 'success';\nEND;\nIF p3.position > 50;\n p3backcol = 'warning';\nEND;\nIF p4.position == 0;\n p4backcol = 'danger';\nEND;\nIF p4.position > 0 && p2.position <= 10;\n p4backcol = 'success';\nEND;\nIF p4.position > 50;\n p4backcol = 'warning';\nEND -%]\n<tr>\n<td>$p1.domain</td>\n<td>$p1.key</td>\n<td class=\"$p1backcol\">$p1.position</td>\n<td class=\"$p2backcol\">$p2.position</td>\n<td class=\"$p3backcol\">$p3.position</td>\n<td class=\"$p4backcol\">$p4.position</td>\n</tr>", "resultsSaveTo": "file", "resultsFileName": "$datefile.format().html", "additionalFormats": [], "resultsUnique": "no", "queriesFrom": "text", "queryFormat": [ "{subs:test-sites} $query" ], "uniqueQueries": false, "saveFailedQueries": false, "iteratorOptions": { "onAllLevels": false, "queryBuildersAfterIterator": false, "queryBuildersOnAllLevels": false }, "resultsOptions": { "overwrite": false }, "doLog": "no", "keepUnique": "No", "moreOptions": true, "resultsPrepend": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <title>Оценка позиций сайтов</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\">\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.css\">\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table-all.min.js\"></script>\n</head>\n<body>\n<div class=\"container\">\n <h2>Позиции</h2>\n <p>Таблица позиций сайтов в поисковой выдаче по указанным ключевым словам</p> \n <table class=\"table table-bordered\" data-sort-name=\"domain\" data-sort-order=\"asc\" data-toggle=\"table\">\n <thead>\n <tr>\n <th data-field=\"domain\" data-align=\"left\" data-sortable=\"true\">Домен</th>\n <th data-field=\"key\" data-align=\"left\" data-sortable=\"true\">Ключевое слово</th>\n <th data-field=\"google1\" data-align=\"center\" data-sortable=\"true\">Google<br>Россия</th>\n <th data-field=\"yandex1\" data-align=\"center\" data-sortable=\"true\">Yandex<br>Россия</th>\n <th data-field=\"google2\" data-align=\"center\" data-sortable=\"true\">Google<br>Украина</th>\n <th data-field=\"yandex2\" data-align=\"center\" data-sortable=\"true\">Yandex<br>Украина</th>\n </tr>\n </thead>\n <tbody>\n ", "resultsAppend": "\n</tbody>\n</table>\n<p align=\"right\"><font face=\"monospace\" size=\"2\" colo=\"silver\"><i>Parsed by <a href=\"http://a-parser.com/\">A-Parser</a>.</i></font></p> \n</div>\n</body>\n</html>", "queryBuilders": [], "resultsBuilders": [], "configOverrides": [], "runTaskOnComplete": null, "useResultsFileAsQueriesFile": false, "runTaskOnCompleteConfig": "default", "toolsJS": "", "prio": 5, "queries": "123" } } JSON;