<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PHP API : api-client-php]]></title><description><![CDATA[<p dir="auto">Hallo Zusammen,</p>
<p dir="auto">ich möchte gerne auf die API von i-doit (open) zugreifen, leider komme ich nicht wirklich weiter. Ich habe die api-client-php heruntergeladen,</p>
<pre><code>cd /home/system/php
composer require idoit/apiclient
</code></pre>
<p dir="auto">aber das Beispiel von der GitHub-Seite funktioniert schon nicht:</p>
<p dir="auto">hello2.php</p>
<pre><code>&lt;?php
use Idoit\APIClient\API;
use Idoit\APIClient\Idoit;

require_once 'vendor/autoload.php';

$api = new API([
    API::URL =&gt; 'https://demo.i-doit.com/src/jsonrpc.php',
    API::KEY =&gt; 'c1ia5q',
    API::USERNAME =&gt; 'admin',
    API::PASSWORD =&gt; 'admin'
]);

$request = new Idoit($api);
$info = $request-&gt;readVersion();

var_dump($info);
</code></pre>
<p dir="auto">php8.0 hello2.php<br />
PHP Fatal error:  Uncaught Error: Class "Idoit\APIClient\API" not found in /home/system/php/hello2.php:8<br />
Stack trace:<br />
#0 {main}<br />
thrown in /home/system/php/hello2.php on line 8</p>
<p dir="auto">die erforderlichen PHP-Module sind installiert</p>
<pre><code>php8.0 -m
[PHP Modules]
bcmath
...
curl
date
...
json
...
openssl
...
zlib
</code></pre>
<p dir="auto">Passe ich das USE an:</p>
<pre><code>&lt;?php

use bheisig\idoitapi\API;
use bheisig\idoitapi\Idoit;

require_once 'vendor/autoload.php';

$api = new API([
    API::URL =&gt; 'https://demo.i-doit.com/src/jsonrpc.php',
    API::KEY =&gt; 'c1ia5q',
    API::USERNAME =&gt; 'admin',
    API::PASSWORD =&gt; 'admin'
]);

$request = new Idoit($api);
$info = $request-&gt;readVersion();

var_dump($info);
</code></pre>
<p dir="auto">ist zumindest das 'Class not found' verschwunden,</p>
<pre><code>php8.0 hello.php 
PHP Fatal error:  Uncaught RuntimeException: Unable to initiate cURL session in /home/system/php/vendor/idoit/apiclient/src/API.php:349
Stack trace:
#0 /home/system/php/vendor/idoit/apiclient/src/API.php(549): bheisig\idoitapi\API-&gt;connect()
#1 /home/system/php/vendor/idoit/apiclient/src/API.php(471): bheisig\idoitapi\API-&gt;execute()
#2 /home/system/php/vendor/idoit/apiclient/src/Idoit.php(45): bheisig\idoitapi\API-&gt;request()
#3 /home/system/php/hello.php(16): bheisig\idoitapi\Idoit-&gt;readVersion()
#4 {main}
  thrown in /home/system/php/vendor/idoit/apiclient/src/API.php on line 349
</code></pre>
<p dir="auto">aber so richtig gut sieht es noch immer nicht aus:</p>
<p dir="auto">Grundsätzlich zugreifen kann ich auf den Server</p>
<pre><code>curl --data '{"version": "2.0","method": "idoit.version","params": {"apikey":"c1ia5q","language": "en"},"id": 1}' --header "Content-Type:application/json" --user admin:admin https://demo.i-doit.com/src/jsonrpc.php

{"id":1,"jsonrpc":"2.0","result":{"login":{"userid":"9","name":"i-doit Systemadministrator ","mail":"i-doit@acme-it.example","username":"admin","tenant":"ACME IT Solutions","language":"en"},"version":"26","step":"","type":"PRO"}}
</code></pre>
<p dir="auto">Ich habe erstmal versucht den Demo-Rechner <a href="https://demo.i-doit.com/src/jsonrpc.php">https://demo.i-doit.com/src/jsonrpc.php</a> zu erreichen um Probleme mit meiner I-Doit Installation auszuschließen. php8.0 nutze ich, da i-Doit in der Version 25 noch "8.0.30 (8.0 recommended)" empfiehlt.</p>
<p dir="auto">Hat jemand einen Tip für mich, was mache ich falsch?<br />
Grüße</p>
]]></description><link>https://community.i-doit.com/topic/4849/php-api-api-client-php</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 07:37:24 GMT</lastBuildDate><atom:link href="https://community.i-doit.com/topic/4849.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Sep 2023 16:42:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PHP API : api-client-php on Mon, 29 Jul 2024 08:29:02 GMT]]></title><description><![CDATA[<p dir="auto">Hallo <a class="plugin-mentions-user plugin-mentions-a" href="/user/uhaase" aria-label="Profile: uhaase">@<bdi>uhaase</bdi></a></p>
<p dir="auto">der API Client unterstützt noch keine der v2 Endpunkte - wobei das bisher auch gar nicht nötig ist. Die v2 Endpunkte wurden in erster Linie ins leben gerufen um die Parameter zu vereinheitlichen (z.B. werden <code>objID</code>, <code>catgID</code> oder <code>catsID</code> mit <code>object</code> und <code>category</code> usw. getauscht) - der API Client übernimmt dies aber schon im Vergleich zur "rohen" Kommunikation mit der API.</p>
<p dir="auto">Ich muss auch gestehen das die v2 Endpunkte nur sehr langsam Fortschritte machen und viele der <code>object</code> und <code>category</code> Endpunkte im v2 Kontext noch nicht existieren, da wir damit auf eine i-doit interne API aufbauen wollen, die noch nicht fertig ist.</p>
<p dir="auto">Ich denke lediglich die <code>cmdb.external.pull.v2</code> und <code>cmdb.external.push.v2</code> müssten wir hier nachziehen, da es sich dabei um neue Endpunkte handelt die vorher nicht existiert haben.</p>
<p dir="auto">Oder wolltest du auf etwas anderes hinaus <img src="https://community.i-doit.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=e20d51f3df8" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title=":thinking_face:" alt="🤔" /> ?</p>
<p dir="auto">Viele Grüße<br />
Leo</p>
]]></description><link>https://community.i-doit.com/post/18113</link><guid isPermaLink="true">https://community.i-doit.com/post/18113</guid><dc:creator><![CDATA[LFischer]]></dc:creator><pubDate>Mon, 29 Jul 2024 08:29:02 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Mon, 29 Jul 2024 07:51:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/lfischer" aria-label="Profile: LFischer">@<bdi>LFischer</bdi></a> die Ankündigung des Anstossens eines neuen Taggings ist nun schon fast wieder ein Jahr her (September 2023). Da das Problem nur hier in diesem Forum mal ansprechend gelöst wurde, wird es wirklich mal Zeit für ein Update...<br />
Sind die Arbeiten für die Unterstützung der REST-APIv2 im Client schon weit fortgeschritten? Würde nämlich gerne die API2 gerne mit dem Client zusammen nutzen...</p>
]]></description><link>https://community.i-doit.com/post/18112</link><guid isPermaLink="true">https://community.i-doit.com/post/18112</guid><dc:creator><![CDATA[uhaase]]></dc:creator><pubDate>Mon, 29 Jul 2024 07:51:29 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Fri, 15 Sep 2023 10:11:40 GMT]]></title><description><![CDATA[<p dir="auto">Hallo <a class="plugin-mentions-user plugin-mentions-a" href="/user/boni127" aria-label="Profile: boni127">@<bdi>boni127</bdi></a></p>
<p dir="auto">ich fürchte das Thema ist tatsächlich etwas komplizierter als zunächst gedacht - das liegt an den verschiedenen Kategorien und Beziehungen zwischen zwei Objekten.</p>
<p dir="auto">Ich habe noch mal reingeschaut. Um die Person einer Organisation zuzuweisen habe ich die Kategorie <code>C__CATS__PERSON_CONTACT_ASSIGNMENT</code> genutzt, das sieht dann so aus:</p>
<pre><code class="language-php">(new CMDBCategory($api))-&gt;save($objectIDp, 'C__CATS__PERSON_CONTACT_ASSIGNMENT', [
    'object' =&gt; $objectIDc,      // Organisation Objekt-ID
    'role'   =&gt; 'Administrator', // Rolle via ID oder String
]);
</code></pre>
<p dir="auto">Viele Grüße<br />
Leo</p>
]]></description><link>https://community.i-doit.com/post/17362</link><guid isPermaLink="true">https://community.i-doit.com/post/17362</guid><dc:creator><![CDATA[LFischer]]></dc:creator><pubDate>Fri, 15 Sep 2023 10:11:40 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Wed, 13 Sep 2023 05:10:03 GMT]]></title><description><![CDATA[<p dir="auto">Moin Leo,</p>
<p dir="auto">ein paar kleine Änderungen musste ich vornehmen, aber so funktioniert es nun.  Allerdings klappt die Zuweisung Person - Organization noch nicht. Mit  C__CATS__ORGANIZATION_CONTACT_ASSIGNMENT wird im Objekt Person die zugeordnete Firma angezeigt, allerdings finde ich dieses Zuweisung nicht in der Organization.</p>
<p dir="auto"><img src="/assets/uploads/files/1694581684307-8b906d73-21fb-436c-8c4d-0081fbaac502-image.png" alt="8b906d73-21fb-436c-8c4d-0081fbaac502-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1694581728217-0fa3456f-5922-47e9-918c-584e125f1f02-image.png" alt="0fa3456f-5922-47e9-918c-584e125f1f02-image.png" class=" img-fluid img-markdown" /></p>
<pre><code>&lt;?php
use Idoit\APIClient\API;
use Idoit\APIClient\Idoit;
use Idoit\APIClient\CMDBObject;
use Idoit\APIClient\CMDBCategory;

require_once 'vendor/autoload.php';

$api = new API([
    API::URL =&gt; 'http://idoit.fritz.box/src/jsonrpc.php',
    API::KEY =&gt; '********',
    API::USERNAME =&gt; 'admin',
    API::PASSWORD =&gt; 'admin'
]);

$objectc = new CMDBObject($api);

#C__CATS__ORGANIZATION
#C__OBJTYPE__ORGANIZATION

$objectIDc = $objectc-&gt;create(
    'C__OBJTYPE__ORGANIZATION',
    'Company2',
    [
        'description' =&gt; 'Hier eine kleine Beschreibung'
    ]
);

var_dump($objectIDc);

(new CMDBCategory($api))-&gt;save($objectIDc, 'C__CATG__ADDRESS', [
    'address'     =&gt; "Mehrzeiliges\nTextfeld",
    'street'      =&gt; 'Musterstraße',
    'house_no'    =&gt; '123 A',
    'stories'     =&gt; 1,
    'postcode'    =&gt; '12345',
    'city'        =&gt; 'Musterstadt',
    'region'      =&gt; 'Region',
    'country'     =&gt; 'Land',
    'description' =&gt; 'Beschreibung',
]);

$objectp = new CMDBObject($api);

$objectIDp = $objectp-&gt;create(
    'C__OBJTYPE__PERSON',
    'Eva Mustermann',
    [
        'description' =&gt; 'Hier eine kleine Beschreibung2',
    ]
);

var_dump($objectIDp);
(new CMDBCategory($api))-&gt;save($objectIDp, 'C__CATS__PERSON_MASTER', [
    'street'      =&gt; 'Musterstraße',
    'city'        =&gt; 'Musterstadt',
    'description' =&gt; 'Beschreibung',
    'mail' =&gt; 'abc@def.de',
    'phone_home' =&gt; '12345',
    'phone_company' =&gt; '123459',
    'phone_mobile' =&gt; '1234587',

]);


(new CMDBCategory($api))-&gt;save($objectIDc, 'C__CATS__ORGANIZATION_CONTACT_ASSIGNMENT', [
    'object' =&gt; $objectIDp,             // Personen Objekt-ID
    'role'   =&gt; 'Administrator', // Rolle via ID oder String
]);


</code></pre>
]]></description><link>https://community.i-doit.com/post/17359</link><guid isPermaLink="true">https://community.i-doit.com/post/17359</guid><dc:creator><![CDATA[boni127]]></dc:creator><pubDate>Wed, 13 Sep 2023 05:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Wed, 06 Sep 2023 12:33:50 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/user/boni127" aria-label="Profile: boni127">@<bdi>boni127</bdi></a></p>
<p dir="auto">also zum hinzufügen einer Adresse benötigst du nur die Objekt ID der entsprechenden Organisation. Anschließend solltest du so etwas hier schreiben und nutzen können:</p>
<pre><code>(new CMDBCategory($api))-&gt;save(123, Category::CATG__ADDRESS, [
    'address'     =&gt; "Mehrzeiliges\nTextfeld",
    'street'      =&gt; 'Musterstraße',
    'house_no'    =&gt; '123 A',
    'stories'     =&gt; 1,
    'postcode'    =&gt; '12345',
    'city'        =&gt; 'Musterstadt',
    'region'      =&gt; 'Region',
    'country'     =&gt; 'Land',
    'description' =&gt; 'Beschreibung',
]);
</code></pre>
<p dir="auto">Für die Personenzuweisung:</p>
<pre><code>(new CMDBCategory($api))-&gt;save(123, Category::CATS__ORGANIZATION_CONTACT_ASSIGNMENT, [
    'object' =&gt; 321,             // Personen Objekt-ID
    'role'   =&gt; 'Administrator', // Rolle via ID oder String
]);
</code></pre>
<p dir="auto">Ich habe den Code jetzt nicht im einzelnen getestet, aber etwa so sollte es aussehen <img src="https://community.i-doit.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=e20d51f3df8" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">VG Leo</p>
]]></description><link>https://community.i-doit.com/post/17345</link><guid isPermaLink="true">https://community.i-doit.com/post/17345</guid><dc:creator><![CDATA[LFischer]]></dc:creator><pubDate>Wed, 06 Sep 2023 12:33:50 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Tue, 05 Sep 2023 16:33:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi Leo,</p>
<p dir="auto">vielen Dank für den Hinweis, da hätte ich sicher lange gesucht.</p>
<p dir="auto">Die ersten Objekte konnte ich nun schon über die API angelegen, habe aber noch ein paar Schwierigkeiten um bspw. die Adresse bei einer Organisation zu setzen oder eine Person einer Organisation zuzuordnen.</p>
<p dir="auto">Kannst Du mir noch einen schubs in die richtige Richtung geben?</p>
<p dir="auto">Grüße Detlev.</p>
]]></description><link>https://community.i-doit.com/post/17344</link><guid isPermaLink="true">https://community.i-doit.com/post/17344</guid><dc:creator><![CDATA[boni127]]></dc:creator><pubDate>Tue, 05 Sep 2023 16:33:50 GMT</pubDate></item><item><title><![CDATA[Reply to PHP API : api-client-php on Tue, 05 Sep 2023 09:35:46 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/user/boni127" aria-label="Profile: boni127">@<bdi>boni127</bdi></a></p>
<p dir="auto">das liegt daran, das wir den API Client schon lange nicht mehr mit einer Version getaggt haben. Die Version 0.10 ist noch aus 2020 - und Composer zieht "by default" nur getaggte Versionen.</p>
<p dir="auto">Um den aktuellsten Stand zu bekommen müsstest du den API Client folgendermaßen anfordern:</p>
<pre><code>composer req "idoit/apiclient:dev-main"
</code></pre>
<p dir="auto">In den letzten drei Jahren wurde der API Client ein wenig umstrukturiert und ist umgezogen - daher die geänderten Namespaces.</p>
<p dir="auto">Ich werde mal anstoßen eine Version zu taggen - es wäre durchaus an der Zeit <img src="https://community.i-doit.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=e20d51f3df8" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
<p dir="auto">Viele Grüße<br />
Leo</p>
]]></description><link>https://community.i-doit.com/post/17343</link><guid isPermaLink="true">https://community.i-doit.com/post/17343</guid><dc:creator><![CDATA[LFischer]]></dc:creator><pubDate>Tue, 05 Sep 2023 09:35:46 GMT</pubDate></item></channel></rss>