- выгрузка файлов с сервера
- загрузка файлов на сервер
- HTTP GET/POST с возможностью прочитать ответ сервера
- Поддержка SSL
Тестировал на протоколах http, https, ftp, sftp, ftpes.
Краткий туториал в файле \doc\How-To.txt.
Модератор: Дед Пахом
Код: Выделить всё
SSHSettings GROUP(TSSHSettings),PRE(SSHSettings)
END
Сегодня прислали запрос на интеграцию с Диадоком, буду смотреть ))Игорь Столяров писал(а): 24 Август 2018, 12:10С Контуром (Диадок) я пробовал работать. В принципе - подключиться получается, но там навёрнутые структуры данных ...
Код: Выделить всё
curl TCurlClass
host STRING('http://testapi.novaposhta.ua/v2.0/json/Address/searchSettlements/')
postparams STRING('{{"apiKey": "","modelName": "Address","calledMethod": "searchSettlements","methodProperties": {{"CityName": "київ","Limit": 5}}')
res CURLcode, AUTO
respBuffer STRING(32768) !big enuff to hold received response
CODE
curl.Init()
curl.AddHttpHeader('Content-Type: application/json') !- or 'Content-Type: text/json'
curl.SetHttpHeaders()
curl.SetCustomRequest('POST')
curl.SetHttpGET(TRUE)
curl.SetSSLVerifyHost(false)
curl.SetSSLVerifyPeer(FALSE)
! set ssl version (see CURL_SSLVERSION_xxx constants)
curl.SetSSLVersion(CURL_SSLVERSION_DEFAULT)
res = curl.SendRequest(host, PostParams, 'rest.txt')
IF res = CURLE_OK
! OK
ELSIF res = -1
MESSAGE('Cannot open local file', 'libcurl', ICON:Exclamation)
ELSE
MESSAGE('SendRequest failed: '& curl.StrError(res), 'libcurl', ICON:Exclamation)
END
Код: Выделить всё
{"success":false,"data":[],"errors":["Data is invalid"],"warnings":[],"info":[],"messageCodes":[],"errorCodes":[],"warningCodes":[],"infoCodes":[]}
на вышеуказанной странице, есть кнопка "отправить", после нажатия которой выводится содержимое ответа на запрос и он отличается от моего, вот оно:
Код: Выделить всё
Pragma: no-cache
Transfer-Encoding: chunked
Vary: Accept-Encoding
Cache-Control: no-store, must-revalidate, no-cache, post-check=0, pre-check=0
Date: Thu, 25 Oct 2018 17:35:07 GMT
Set-Cookie: PHPSESSID=7msaf4scj870vb2lsse2euhcg0; path=/
Content-Type: application/json
Expires: Thu, 19 Nov 1981 08:52:00 GMT
{
"success": true,
"data": [{
"TotalCount": 9,
"Addresses": [{
"Present": "\u043c. \u041a\u0438\u0457\u0432, \u041a\u0438\u0457\u0432\u0441\u044c\u043a\u0430 \u043e\u0431\u043b.",
"Warehouses": 471,
"MainDescription": "\u041a\u0438\u0457\u0432",
"Area": "\u041a\u0438\u0457\u0432\u0441\u044c\u043a\u0430",
"Region": "",
"SettlementTypeCode": "\u043c.",
"Ref": "e718a680-4b33-11e4-ab6d-005056801329",
"DeliveryCity": "8d5a980d-391c-11dd-90d9-001a92567626",
"StreetsAvailability": true,
"ParentRegionTypes": "\u043e\u0431\u043b\u0430\u0441\u0442\u044c",
"ParentRegionCode": "\u043e\u0431\u043b.",
"RegionTypes": "",
"RegionTypesCode": ""
}, {
"Present": "\u0441. \u041a\u0438\u0457\u0432, \u0414\u043e\u043c\u0430\u043d\u0456\u0432\u0441\u044c\u043a\u0438\u0439 \u0440-\u043d, \u041c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0430 \u043e\u0431\u043b.",
"Warehouses": 0,
"MainDescription": "\u041a\u0438\u0457\u0432",
"Area": "\u041c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0430",
"Region": "\u0414\u043e\u043c\u0430\u043d\u0456\u0432\u0441\u044c\u043a\u0438\u0439",
"SettlementTypeCode": "\u0441.",
"Ref": "0db2df4b-4b3a-11e4-ab6d-005056801329",
"DeliveryCity": "06f8795a-4079-11de-b509-001d92f78698",
"StreetsAvailability": false,
"ParentRegionTypes": "\u043e\u0431\u043b\u0430\u0441\u0442\u044c",
"ParentRegionCode": "\u043e\u0431\u043b.",
"RegionTypes": "\u0440\u0430\u0439\u043e\u043d",
"RegionTypesCode": "\u0440-\u043d"
}, {
"Present": "\u0441. \u041a\u0438\u0457\u0432\u0435\u0446\u044c, \u041c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0438\u0439 \u0440-\u043d, \u041b\u044c\u0432\u0456\u0432\u0441\u044c\u043a\u0430 \u043e\u0431\u043b.",
"Warehouses": 0,
"MainDescription": "\u041a\u0438\u0457\u0432\u0435\u0446\u044c",
"Area": "\u041b\u044c\u0432\u0456\u0432\u0441\u044c\u043a\u0430",
"Region": "\u041c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0438\u0439",
"SettlementTypeCode": "\u0441.",
"Ref": "0df25497-4b3a-11e4-ab6d-005056801329",
"DeliveryCity": "acecfca8-1488-11df-8caf-000c2965ae0e",
"StreetsAvailability": false,
"ParentRegionTypes": "\u043e\u0431\u043b\u0430\u0441\u0442\u044c",
"ParentRegionCode": "\u043e\u0431\u043b.",
"RegionTypes": "\u0440\u0430\u0439\u043e\u043d",
"RegionTypesCode": "\u0440-\u043d"
}, {
"Present": "\u0441. \u041a\u0438\u0457\u0432\u043a\u0430, \u0413\u043e\u043b\u043e\u043f\u0440\u0438\u0441\u0442\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0440-\u043d, \u0425\u0435\u0440\u0441\u043e\u043d\u0441\u044c\u043a\u0430 \u043e\u0431\u043b.",
"Warehouses": 0,
"MainDescription": "\u041a\u0438\u0457\u0432\u043a\u0430",
"Area": "\u0425\u0435\u0440\u0441\u043e\u043d\u0441\u044c\u043a\u0430",
"Region": "\u0413\u043e\u043b\u043e\u043f\u0440\u0438\u0441\u0442\u0430\u043d\u0441\u044c\u043a\u0438\u0439",
"SettlementTypeCode": "\u0441.",
"Ref": "0dd153b3-4b3a-11e4-ab6d-005056801329",
"DeliveryCity": "db5c88e7-391c-11dd-90d9-001a92567626",
"StreetsAvailability": false,
"ParentRegionTypes": "\u043e\u0431\u043b\u0430\u0441\u0442\u044c",
"ParentRegionCode": "\u043e\u0431\u043b.",
"RegionTypes": "\u0440\u0430\u0439\u043e\u043d",
"RegionTypesCode": "\u0440-\u043d"
}, {
"Present": "\u0441. \u041a\u0438\u0457\u0432\u0441\u044c\u043a\u0435, \u041d\u043e\u0432\u043e\u043c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0438\u0439 \u0440-\u043d, \u0417\u0430\u043f\u043e\u0440\u0456\u0437\u044c\u043a\u0430 \u043e\u0431\u043b.",
"Warehouses": 0,
"MainDescription": "\u041a\u0438\u0457\u0432\u0441\u044c\u043a\u0435",
"Area": "\u0417\u0430\u043f\u043e\u0440\u0456\u0437\u044c\u043a\u0430",
"Region": "\u041d\u043e\u0432\u043e\u043c\u0438\u043a\u043e\u043b\u0430\u0457\u0432\u0441\u044c\u043a\u0438\u0439",
"SettlementTypeCode": "\u0441.",
"Ref": "0e40bf5a-4b3a-11e4-ab6d-005056801329",
"DeliveryCity": "cfbeaca4-4063-11de-b509-001d92f78698",
"StreetsAvailability": false,
"ParentRegionTypes": "\u043e\u0431\u043b\u0430\u0441\u0442\u044c",
"ParentRegionCode": "\u043e\u0431\u043b.",
"RegionTypes": "\u0440\u0430\u0439\u043e\u043d",
"RegionTypesCode": "\u0440-\u043d"
}]
}],
"errors": [],
"warnings": [],
"info": [],
"messageCodes": [],
"errorCodes": [],
"warningCodes": [],
"infoCodes": []
}
Вот это по-моему ясно говорит, что с исходными данными что-то не так. Возможно, apiKey должен быть непустым (на сайте так и написано).
Выберите на станице выше формат - json, чтобы Request URL стал такимДед Пахом писал(а): 26 Октябрь 2018, 11:13не знаю, жму Отправить и получаю "Your request is wrong. Refer to the documentation <a href="https://devcenter.novaposhta.ua">devcenter.novaposhta.ua</a>"
Код: Выделить всё
postparams STRING('{{"apiKey": "","modelName": "Address","calledMethod": "searchSettlements","methodProperties": {{"CityName": "\u043A\u0438\u0457\u0432","Limit": 5}}')
Спасибо огромное, без вашей помощи вряд ли решилось бы )