getKey('apiurl', 'shlink'); $shlink_api_key = $conf->getKey('apikey', 'shlink'); if (empty($shlink_api_url) || empty($shlink_api_key)) { return; } $body = array( 'longUrl' => $link, ); return file_get_contents( $shlink_api_url, false, stream_context_create( array( 'http' => array( 'method' => 'POST', 'header' => "Content-Type: application/json\r\n" . 'X-Api-Key: ' . $shlink_api_key . "\r\n", 'content' => Json::encode($body), ), ) ) ); } /** * Extracts the short URL from the shlink API response. * * @access protected * @param array $data * @return ?string */ protected function _extractShortUrl(array $data): ?string { if ( !is_null($data) && array_key_exists('shortUrl', $data) ) { return $data['shortUrl']; } return null; } }