git.schokokeks.org
Repositories
Help
Report an Issue
bibweb.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
40e4230
Branches
Tags
master
bibweb.git
lib
api.php
API-Authtoken, Idle-Warnung, Abstraktion
Bernd Wurst
commited
40e4230
at 2020-06-07 07:15:34
api.php
Blame
History
Raw
<?php require_once dirname(__DIR__).'/config.php'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTPHEADER => array("Content-Type: application/json"), CURLOPT_CUSTOMREQUEST => "POST")); function api_call($path, $data) { global $curl; global $config; $data['authtoken'] = $config['api_token']; curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl, CURLOPT_URL, $config['api_url'].$path); $response = curl_exec($curl); $err = curl_error($curl); $ret = @json_decode($response, true); if (!isset($ret['status']) || $ret['status'] == 'error') { echo $response; } return $ret; }