Answer the question
In order to leave comments, you need to log in
How to start working with the REST api of a specific software?
Good afternoon!
There is a site with Bitrix on one side and on the other side the Info-system "MIS Infoclinic" with REST api
How to make a request using PHP from the site and get data from the MIS?
I understand that this is a very, very general question, but I do
n’t even know where to start to understand this
. , the question is how to connect it, how to receive data
Is it necessary to deploy some kind of server on the MIS side that will give answers or is everything easier
I ask those who have done something similar and clearly understand where to dig
Answer the question
In order to leave comments, you need to log in
1. There is no need to deploy anything on the MIS server
2. On your website, make a module or function (I didn’t work with Bitrix, I don’t know how it was) with curl or guzzle in it, make a request to the MIS server with the necessary parameters
3. You get a response, parse it depending on what format it is in
. 4. Put the received data into the database or do whatever you want with them
. 5. Make the same request after the required period of time or another one with different parameters. And that's it.
If you are familiar with php, then php.net / Curl will help you further, you need to look at the API docks, which methods are there for which requests, so to speak.
Use built-in httpClient.
Example:
/**
* @param array $options Optional array with options:
* "redirect" bool Follow redirects (default true)
* "redirectMax" int Maximum number of redirects (default 5)
* "waitResponse" bool Wait for response or disconnect just after request (default true)
* "socketTimeout" int Connection timeout in seconds (default 30)
* "streamTimeout" int Stream reading timeout in seconds (default 60)
* "version" string HTTP version (HttpClient::HTTP_1_0, HttpClient::HTTP_1_1) (default "1.0")
* "proxyHost" string Proxy host name/address
* "proxyPort" int Proxy port number
* "proxyUser" string Proxy username
* "proxyPassword" string Proxy password
* "compress" bool Accept gzip encoding (default false)
* "charset" string Charset for body in POST and PUT
* "disableSslVerification" bool Pass true to disable ssl check.
* All the options can be set separately with setters.
*/
$options = [
'socketTimeout' => 5,
'streamTimeout' => 15,
];
$httpClient = new \Bitrix\Main\Web\HttpClient($options);
// get-запрос
$response = $httpClient->get('http://site.ru/path/to/url/?query');
// post-запрос
$response = $httpClient->post('http://site.ru/path/to/url/?query', [
'param1' => 'value1',
]);
// head-запрос
$response = $httpClient->head('http://site.ru/path/to/url/?query');
// возможные ошибки
$errors = $httpClient->getError();
// Статус ответа
$errors = $httpClient->getStatus();
Use curl on the Bitrix side + info system API documentation to create the right requests.
It's all.
just echo file_get_contents (link with parameters to the script that will generate json)
and then parse based on the answer,
well, if json is the format, then json_decode
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question