|
0
BenDiget
30.11.25
✎
23:10
|
Привет всем!
Я пытаюсь через http получить заявки оставленные на сайте. Но ответом получаю 302 - запрошенный ресурс временно находится на другом адресе. К слову, это моя первая попытка установить соединение с сайтом.
Заголовки = Новый Соответствие();
ЗащищенноеСоединение = Новый ЗащищенноеСоединениеOpenSSL();
SLL = Новый ЗащищенноеСоединениеOpenSSL;
HttpСоединение = Новый HTTPСоединение("tilda.cc", ,"МояПочта@gmail.com", "МойПароль",,,ЗащищенноеСоединение);
Сервис = "projects/leads/?projectid=18431817";
HTTPЗапрос = Новый HTTPЗапрос(Сервис,Заголовки);
HttpОтвет = HttpСоединение.Получить(HTTPЗапрос);
JsonОтвет = HttpОтвет.ПолучитьТелоКакСтроку(КодировкаТекста.UTF8);
|
|
|
2
dmt
01.12.25
✎
08:50
|
ИИ отвечает
Requirements:
Plan: Tilda Business (usually required for API access).
Keys: Get Public Key and Secret Key in Site Settings → Export → API Integration.
Подробности
Function GetTildaLeads()
PublicKey = "YOUR_PUBLIC_KEY";
SecretKey = "YOUR_SECRET_KEY";
// Establish secure connection
SSL = New OpenSSLSecureConnection();
Host = "api.tildacdn.info";
Connection = New HTTPConnection(Host, 443, , , , , SSL);
// Construct URL with parameters
// Note: It's better to use current timestamp/signature if required by stricter security settings,
// but basic auth uses keys directly in URL for simple calls.
ResourceAddress = "/v1/getleadslist/?publickey=" + PublicKey + "&secretkey=" + SecretKey;
Request = New HTTPRequest(ResourceAddress);
Try
Response = Connection.Get(Request);
Except
// Handle connection errors
Return Undefined;
EndTry;
If Response.StatusCode = 200 Then
// Parse JSON response
JSONReader = New JSONReader;
JSONReader.SetString(Response.GetBodyAsString());
Data = ReadJSON(JSONReader);
JSONReader.Close();
Return Data;
Else
// If you still get 302, check the "Location" header
If Response.StatusCode = 302 Then
NewLocation = Response.Headers.Get("Location");
Message("Resource moved to: " + NewLocation);
EndIf;
Message("Error: " + Response.StatusCode);
EndIf;
EndFunction
|
|