$config['api_username'], "password" => $config['api_password'] ]; $options = array( 'http' => array( 'method' => 'POST', 'content' => json_encode( $data ), 'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n" ) ); $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $response = json_decode( $result, true); $jwt_token = $response["token"]; $jwt_refresh_token = $response["refresh_token"]; function api_call($method, $url, $content = []) { global $jwt_token; global $base_url; $url = $base_url . $url; $options = array( 'http' => array( 'method' => strtoupper($method), 'content' => json_encode( $content ), 'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n" . "Authorization: Bearer ".$jwt_token."\r\n" ) ); $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $response = json_decode( $result, true ); return $response; } require_once('vendor/autoload.php'); function format_number_api($number) { $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneNumberUtil->parse($number, 'DE'); } catch (Exception $e) { return NULL; } if ($phoneNumberUtil->isValidNumber($phoneNumber)) { return $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::E164); } return NULL; }