{
    "version": "https:\/\/jsonfeed.org\/version\/1.1",
    "title": "IT science: заметки с тегом автоматизация",
    "_rss_description": "IT science — статьи и инструкции из мира IT",
    "_rss_language": "ru",
    "_itunes_email": "",
    "_itunes_categories_xml": "",
    "_itunes_image": "",
    "_itunes_explicit": "",
    "home_page_url": "https:\/\/itscience.pro\/tags\/avtomatizaciya\/",
    "feed_url": "https:\/\/itscience.pro\/tags\/avtomatizaciya\/json\/",
    "icon": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154",
    "authors": [
        {
            "name": "IT science",
            "url": "https:\/\/itscience.pro\/",
            "avatar": "https:\/\/itscience.pro\/pictures\/userpic\/userpic@2x.jpg?1658757154"
        }
    ],
    "items": [
        {
            "id": "41",
            "url": "https:\/\/itscience.pro\/all\/massovaya-registraciya-graphisoft-id\/",
            "title": "массовая регистрация graphisoft id",
            "content_html": "<p>Встал вопрос получить сотрудникам Graphisoft id, но никакого функционала у производителя нет, чтобы сделать это массово.  Печаль.<\/p>\n<div class=\"e2-text-picture\">\n<img src=\"https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png\" width=\"250\" height=\"237\" alt=\"\" \/>\n<\/div>\n<p>Итак, проанализировав механизм регистрации и добавления пользователя в состав компании получаем следующий алгоритм:<\/p>\n<ol start=\"1\">\n<li>регистрация пользователя на сайте graphisoft.com<\/li>\n<li>подтверждение регистрации в посте пользователя<\/li>\n<li>авторизация на сайте graphisoft.com под административной учетной записью<\/li>\n<li>отправка приглашения пользователю<\/li>\n<li>авторизация  на сайте graphisoft.com под пользовательской учетной записью<\/li>\n<li>подтверждение приглашения<\/li>\n<\/ol>\n<p>как родилось решение описано тут:<br \/>\n<a href=\"https:\/\/voronin.one\/all\/kak-nelzya-otnositsya-k-korporativnym-klientam\/\">1 часть, «как нельзя относиться к корпоративным клиентам»<\/a><br \/>\n<a href=\"https:\/\/voronin.one\/all\/analiz-poluchenie-ishodnyh-dannyh\/\">2 часть, «анализ, получение исходных данных»<\/a><br \/>\n<a href=\"https:\/\/voronin.one\/all\/kropotlivaya-rabota-i-dolgozhdanny-uspeh\/\">3 часть, «кропотливая работа и долгожданный успех»<\/a><\/p>\n<p>получилось неплохо, полностью автоматизированная система, работает следующим образом:<br \/>\nпри появлении нового сотрудника создается для него graphisoft id, добавляется в состав компании и на почту высылаются данные с логином и паролем, а так же инструкция по использованию последних;<br \/>\nпосле увольнения сотрудника или ухода в декрет — graphisoft id исключается из списка сотрудников компании.<\/p>\n<p>ниже сам код регистрации одно пользователя, как сделать это массово — я думаю разберетесь<\/p>\n<pre class=\"e2-text-code\"><code class=\"\">&lt;?php\n\n\/\/ данные регистрируемого сотрудника\n$fname = &#039;Иван&#039;;\n$sname = &#039;Петров&#039;;\n$email = &#039;user@domain.ru&#039;;\n$pasword = &#039;koo0ovo5Kamu&#039;;\n\n\/\/ данные администратора компании\n$admin_login = &#039;admin@domain.ru&#039;;\n$admin_password = &#039;P@5$w0rD&#039;;\n\n$header = &#039;&#039;;\n\nfunction get_url($url, $method, $ctype, $referer, $data) {\n\t$ch = curl_init();\n\tcurl_setopt($ch, CURLOPT_URL, $url);\n\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\tcurl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);\n\tif ($data!==&#039;&#039;) {\n\t\tif ($ctype == 1) {\n\t\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));\n\t\t} else if ($ctype == 2) {\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));\n\t\t} else if ($ctype == 3) {\n\t\t\tcurl_setopt($ch, CURLOPT_HEADER, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_POST, 1);\n\t\t\tcurl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);\n\t\t\tcurl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));\n\t\t}\n\t}\n\tcurl_setopt($ch, CURLOPT_ENCODING, &#039;gzip, deflate&#039;);\n\t$headers = array();\n\t$headers[] = &#039;Connection: keep-alive&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua: \\&quot; Not;A Brand\\&quot;;v=\\&quot;99\\&quot;, \\&quot;Opera\\&quot;;v=\\&quot;79\\&quot;, \\&quot;Chromium\\&quot;;v=\\&quot;93\\&quot;&#039;;\n\t$headers[] = &#039;Dnt: 1&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua-Mobile: ?0&#039;;\n\t$headers[] = &#039;User-Agent: Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/93.0.4577.63 Safari\/537.36 OPR\/79.0.4143.22&#039;;\n\tif ($ctype == 1) {\n\t\t$headers[] = &#039;Content-Type: application\/json; charset=UTF-8&#039;;\n\t} else {\n\t\t$headers[] = &#039;Content-Type: application\/x-www-form-urlencoded; charset=UTF-8&#039;;\n\t}\n\t$headers[] = &#039;Accept: application\/json, text\/javascript, *\/*; q=0.01&#039;;\n\t$headers[] = &#039;X-Requested-With: XMLHttpRequest&#039;;\n\t$headers[] = &#039;Sec-Ch-Ua-Platform: \\&quot;Windows\\&quot;&#039;;\n\t$headers[] = &#039;Sec-Fetch-Site: same-origin&#039;;\n\t$headers[] = &#039;Sec-Fetch-Mode: cors&#039;;\n\t$headers[] = &#039;Sec-Fetch-Dest: empty&#039;;\n\t$headers[] = &#039;Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7&#039;;\n\t$headers[] = &#039;Origin: &#039;.$referer;\n\t$headers[] = &#039;Referer: &#039;.$referer;\n\tcurl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n\tcurl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\tcurl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t$response = curl_exec($ch);\n\tglobal $header;\n\t$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);\n\t$header = substr($response, 0, $header_size);\n\treturn $response;\n\tif (curl_errno($ch)) {\n\t\techo &#039;Error:&#039; . curl_error($ch);\n\t}\n\tcurl_close($ch);\n}\n\n\/\/ удаляем старые куки\nif (file_exists(dirname(__FILE__).&#039;\/cookie.txt&#039;)) {\n   unlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n}\t\t\n\/\/ заходим на главную\nget_url(&#039;https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\/\/ переходим на форму пользователя\nget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/Account\/ServiceLogin?Application=GRAPHISOFT&amp;ReturnUrl=https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;&#039;);\n\/\/ переходим на форму регистрации\nget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/#\/register\/3\/https%3a%2f%2fgraphisoft.com%2fru&#039;,&#039;GET&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;&#039;);\n\n\/\/проверяем e-mail\n$check_mail = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/CheckEmail\/&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,array(&quot;EmailAddress&quot; =&gt; $email));\nif ($check_mail == &#039;true&#039;) {\n\t$data = array(&#039;applicationName&#039; =&gt; null,\n\t\t\t\t  &#039;customDataObject&#039; =&gt; null,\n\t\t\t\t  &#039;redirectUrl&#039; =&gt; null,\n\t\t\t\t  &#039;emailHintLocalizationKey&#039; =&gt; null,\n\t\t\t\t  &#039;firstName&#039; =&gt; $fname,\n\t\t\t\t  &#039;lastName&#039; =&gt; $sname,\n\t\t\t\t  &#039;isValidated&#039; =&gt; true,\n\t\t\t\t  &#039;email&#039; =&gt; $email,\n\t\t\t\t  &#039;password&#039; =&gt; $pasword,\n\t\t\t\t  &#039;confirmPassword&#039; =&gt; $pasword,\n\t\t\t\t  &#039;isPrivacyPolicyAccepted&#039; =&gt; true,\n\t\t\t\t  &#039;companyName&#039; =&gt; &#039;ООО &quot;Рога и Копыта&quot;&#039;,\n\t\t\t\t  &#039;countryId&#039; =&gt; 186,\n\t\t\t\t  &#039;federated&#039; =&gt; false,\n\t\t\t\t  &#039;callbackUrl&#039; =&gt; &#039;https:\/\/graphisoft.com\/ru&#039;,\n\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t  &#039;errors&#039; =&gt; array());\n\n\t\/\/echo json_encode($data).&quot;\\n&quot;;\n\n\t$ecoded_json = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/CreateUser&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\n\t$jsonObj = json_decode($ecoded_json);\n\n\tif ($jsonObj === null &amp;&amp; json_last_error() !== JSON_ERROR_NONE) {\n\t   echo &quot;у меня не получилось отправить регистрационную форму с данными...  извините\\n&quot;;\n\t} else {\n\t\t\/\/ удаляем старые куки\n\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\tget_url($jsonObj-&gt;{&#039;VerificationURL&#039;}.$jsonObj-&gt;{&#039;VerificationCode&#039;},&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t$gsid_url = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/VerifyUser&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,array(&quot;code&quot; =&gt; $jsonObj-&gt;{&#039;VerificationCode&#039;}));\n\t\t$parts = parse_url($gsid_url);\n\t\tparse_str($parts[&#039;query&#039;], $query);\n\t\t$user_gsid = $query[&#039;gsid&#039;];\n\t\tif ($user_gsid !== &#039;&#039;) {\n\t\t\techo &quot;пользователь &quot;.$email.&quot; успешно зарегистрирован (Graphisoft sid: &quot;.$user_gsid.&quot;)\\n&quot;;\n\t\t\t\/\/ удаляем старые куки\n\t\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\t\t\/\/ заходим на главную\n\t\t\tget_url(&#039;https:\/\/graphisoft.com\/ru&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\t\/\/ авторизуемся под пользователем\n\t\t\t$data = array(&#039;email&#039; =&gt; $admin_login,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;isNullo&#039; =&gt; false,\n\t\t\t\t\t\t  &#039;password&#039; =&gt; $admin_password);\t\t\t\n\t\t\t$json_response = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/Authenticate\/Login&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t$obj = json_decode($json_response);\n\t\t\t$companyGsId = $obj-&gt;{&#039;Company&#039;}-&gt;{&#039;GsId&#039;};\n\t\t\t\/\/ Загружаем список подключенных пользователей\n\t\t\tforeach ($obj-&gt;{&#039;Company&#039;}-&gt;{&#039;CompanyUsers&#039;} as $user) {\n\t\t\t\t$users_list[] = array(&quot;FirstName&quot; =&gt; $user-&gt;{&#039;FirstName&#039;},&quot;LastName&quot; =&gt; $user-&gt;{&#039;LastName&#039;},&quot;EmailAddress&quot; =&gt; $user-&gt;{&#039;EmailAddress&#039;},&quot;GsId&quot; =&gt; $user-&gt;{&#039;GsId&#039;});\n\t\t\t}\n\n\n\t\t\t$data = array(&#039;companyGsId&#039; =&gt; $companyGsId,\n\t\t\t\t\t\t  &#039;email&#039; =&gt; $email,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;requestedGraphisoftUserId&#039; =&gt; $user_gsid);\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/SendInvitation&#039;,&#039;PUT&#039;,2,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\techo &quot;выслано приглашение присоединиться к компании\\n&quot;;\n\t\t\t\/\/ удаляем старые куки\n\t\t\tunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n\t\t\t\/\/ переходим на форму пользователя\n\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,&#039;GET&#039;,1,&#039;&#039;,&#039;&#039;);\n\t\t\t\/\/ авторизуемся под пользователем\n\t\t\t$data = array(&#039;email&#039; =&gt; $email,\n\t\t\t\t\t\t  &#039;errors&#039; =&gt; array(),\n\t\t\t\t\t\t  &#039;isDirty&#039; =&gt; true,\n\t\t\t\t\t\t  &#039;isNullo&#039; =&gt; false,\n\t\t\t\t\t\t  &#039;password&#039; =&gt; $pasword);\t\t\t\n\t\t\t$json_response = get_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/Authenticate\/Login&#039;,&#039;POST&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t$obj = json_decode($json_response);\n\t\t\t$user_gsid = $obj-&gt;{&#039;GraphisoftUser&#039;}-&gt;{&#039;GsId&#039;};\n\t\t\tif ($user_gsid == &#039;&#039;) {\n\t\t\t\techo &quot;не смог зайти под пользователем в личный кабинет\\n&quot;;\n\t\t\t} else {\n\t\t\t\t$data = array(&#039;actionId&#039; =&gt; 2,\n\t\t\t\t\t\t\t  &#039;companyGsId&#039; =&gt; $companyGsId,\n\t\t\t\t\t\t\t  &#039;graphisoftUserGsId&#039; =&gt; $user_gsid,\n\t\t\t\t\t\t\t  &#039;reactionId&#039; =&gt; 1);\n\t\t\t\tget_url(&#039;https:\/\/graphisoftid.graphisoft.com\/api\/user\/ProcessingPendingRequest&#039;,&#039;PUT&#039;,1,&#039;https:\/\/graphisoftid.graphisoft.com\/&#039;,$data);\n\t\t\t\techo &quot;сотрудник подтвердил приглашение\\n&quot;;\n\t\t\t}\n\t\t} else {\n\t\t\techo &quot;у меня не получилось подтвердить регистрацию...  извините\\n&quot;;\n\t\t}\n\t}\n} else {\n\techo &quot;$email уже зарегистрирован в системе\\n&quot;;\n}\n\/\/ удаляем старые куки\nunlink(dirname(__FILE__).&#039;\/cookie.txt&#039;);\n?&gt;<\/code><\/pre>",
            "date_published": "2021-09-24T18:45:02+03:00",
            "date_modified": "2021-09-24T18:44:58+03:00",
            "tags": [
                "argicad",
                "graphisoft",
                "php",
                "автоматизация"
            ],
            "image": "https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png",
            "_date_published_rfc2822": "Fri, 24 Sep 2021 18:45:02 +0300",
            "_rss_guid_is_permalink": "false",
            "_rss_guid": "41",
            "_e2_data": {
                "is_favourite": false,
                "links_required": [
                    "highlight\/highlight.js",
                    "highlight\/highlight.css"
                ],
                "og_images": [
                    "https:\/\/itscience.pro\/pictures\/izobrazhenie_2021-09-24_184451.png"
                ]
            }
        }
    ],
    "_e2_version": 4171,
    "_e2_ua_string": "Aegea 11.4 (v4171)"
}