getKey('apiurl', 'yourls'); if (empty($yourls_api_url)) { return null; } return file_get_contents( $yourls_api_url, false, stream_context_create( array( 'http' => array( 'method' => 'POST', 'header' => "Content-Type: application/x-www-form-urlencoded\r\n", 'content' => http_build_query( array( 'signature' => $conf->getKey('signature', 'yourls'), 'format' => 'json', 'action' => 'shorturl', 'url' => $link, ) ), ), ) ) ); } /** * Extracts the short URL from the YOURLS API response. * * @access protected * @param array $data * @return ?string */ protected function _extractShortUrl(array $data): ?string { if ( !is_null($data) && array_key_exists('statusCode', $data) && $data['statusCode'] == 200 && array_key_exists('shorturl', $data) ) { return $data['shorturl']; } return null; } }