C
C
calvin_orange2017-11-26 14:10:42
API
calvin_orange, 2017-11-26 14:10:42

How to set up a server to receive XML from 1C without Bitrix and other CMS?

It is necessary to configure the receipt of data (list of goods, cost, stock balance) from 1C to the site.
The site does not have Bitrix and there are no 1C products.
In this regard, the following points are of interest:
1. How can the server be configured so that it can receive XML from the standard data exchange with the website?
What should be the server's response so that 1C sends XML with data from the program's function "Standard data exchange with a website"?
2. Does 1C transfer any other data to the server except for the XML file through data exchange?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-11-26
@Maksclub

1. This is how the php script works (it is the only one) according to the CommerceML standard (this is the one that is standard in Bitrix) in the Simpla engine
https://github.com/pikusov/Simpla/blob/master/simp...
the script loads goods from categories (import), and offers (offers) and pictures, also gives orders from 1C to her
2. Pictures are still usually transferred, but this is not always ....
It is clear that it works according to a certain database structure

A
Alexey Likhachev, 2017-12-07
@Playbot

Accepting files through the standard goods exchange mechanism is not difficult. Attached is an example script. Further, it will send you 2 xml files and pictures to the directory, go through them and put them where you want. But things are much more complicated if you want to forward accounts through the same standard exchange mechanism

php script example
$user	= "1c_user";
        $pass	= "1c_pass";
        $path	= "upload/";

        if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER["PHP_AUTH_PW"]) && !isset($_REQUEST["type"])) {
            header('WWW-Authenticate: Basic realm="1C-Exchange"');
            header('HTTP/1.0 401 Unauthorized');
            $_SESSION["login"] = false;
            die("failure");
        }

        if (($_SERVER["PHP_AUTH_USER"] == $user && $_SERVER["PHP_AUTH_PW"] == $pass) || $_SESSION["login"]) {
            $_SESSION["login"] = true;
            if ($_REQUEST["type"] == "catalog") {
                switch ($_REQUEST["mode"]):
                    case "checkauth":
                        die("success");
                        break;
                    case "init":
                        die("zip=no" . "\r\n" . "file_limit=0");
                        break;
                    case "file":
                        $filename = (strpos($_REQUEST["filename"], ".") == 0) ? substr($_REQUEST["filename"], 1) : $_REQUEST["filename"];
                        $dirname = dirname($path . $filename);
                        if (!is_dir($dirname))
                            mkdir($dirname, 0755, true);
                        $file = fopen($path . $filename, 'ab') or die("failure");
                        fwrite($file, file_get_contents('php://input'));
                        fclose($file);
                        die("success");
                        break;
                endswitch;
            }
            if ($_REQUEST["type"] == "sale") {

            }
        } else {
            header('WWW-Authenticate: Basic realm="1C-Exchange"');
            header('HTTP/1.0 401 Unauthorized');
            $_SESSION["login"] = false;
            die("failure");
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question