PHP code example of optigov / optigov-api-php

1. Go to this page and download the library: Download optigov/optigov-api-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

optigov / optigov-api-php example snippets


$optiGov = new \OptiGov\Client(API_ENDPUNKT, OAUTH_AUTH_ENDPUNKT, OAUTH_TOKEN_ENDPUNKT);

$optiGov->dienstleistung($id);
$optiGov->dienstleistungName($id);

$optiGov->einrichtung($id);
$optiGov->einrichtungName($id);

$optiGov->mitarbeiter($id);
$optiGov->mitarbeiterName($id);

// get data needed for OAuth2.0 authorization
$oauthInformation = $optiGov->oauthAuthorize(
    OPTIGOV_OAUTH_CLIENT_ID,
    OPTIGOV_OAUTH_CLIEBNT_REDIRECT_URL,
);

// get state and code verifier and authorization url
$state = $oauthInformation["state"];
$codeVerifier = $oauthInformation["code_verifier"];
$url = $oauthInformation["url"];

// get tokens form oauth token endpoint
$tokens = $optiGov->oauthGetTokens(
    $codeVerifier, // code verifier from step one
    $_GET["code"], // code from the get parameters
    OPTIGOV_OAUTH_CLIENT_ID,
    OPTIGOV_OAUTH_CLIEBNT_REDIRECT_URL,
);

$optiGov->verwaltung($id)->alleDienstleistungen();

$optiGov->verwaltung($id)->alleThemenfelder();

$optiGov->verwaltung($id)->alleEinrichtungen();

$optiGov->verwaltung($id)->alleMitarbeiter();

$optiGov->buerger(REFRESH_TOKEN)->alleAntraege();

$optiGov->buerger(REFRESH_TOKEN)->alleTermine();

$optiGov->buerger(REFRESH_TOKEN)->alleChats();

$optiGov->buerger(REFRESH_TOKEN)->chat($id);

$optiGov->buerger(REFRESH_TOKEN)->daten();

$optiGov->buerger(REFRESH_TOKEN)->stelleAntrag(
    FORMULAR_ID,
    SUCCESS_REDIRECT_URL,
    [
        "AS.Daten.Parkzone" => "Zone F",
        "cancelUrl" => CANCEL_REDIRECT_URL,
    ]
);

$optiGov->buerger(REFRESH_TOKEN)->dateiHochladen($pfad, $name, $bezeichner);

$optiGov->buerger(REFRESH_TOKEN)->loescheBuerger();

$optiGov->buerger(REFRESH_TOKEN)->erstelleChat($name, $mitarbeiterId);

$optiGov->buerger(REFRESH_TOKEN)->sendeNachricht($inhalt, $chatId, dateien: []);

const BACKEND_URL = "https://..."; // API-Endpunkt
const REFRESH_TOKEN = "..."; // Refresh-Token eines Bürgers
const TEST_CHAT_ID = -1; // ID eines Chats, welcher dem Bürger gehört
const TEST_ANTRAG_FORMULAR_ID = -1; // ID eines Antrags, welcher im Namen des Bürgers gestellt wird
const TEST_ANTRAG_WEITERLEITUNG_URL = "https://..."; // Ziel-URL für erfolgreiche Weiterleitung nach Antragdurchführung
const TEST_ANTRAG_PARAMETER = []; // Parameter, welche dem Antrag übergeben werden
bash
composer