Back to Totp class

Method getUrl

public string
getUrl
(mixed $user, mixed $hostname, mixed $secret)
Returns a QR code URL for easy setup of TOTP apps like Google Authenticator
Parameters
  • string $user User
  • string $hostname Hostname
  • string $secret Secret string
Returns
  • string
Class: Totp
Project: Joomla

Method getUrl - Source code

/**
 * Returns a QR code URL for easy setup of TOTP apps like Google Authenticator
 *
 * @param   string  $user      User
 * @param   string  $hostname  Hostname
 * @param   string  $secret    Secret string
 *
 * @return  string
 */
public function getUrl($user, $hostname, $secret)
{
    $url = sprintf("otpauth://totp/%s@%s?secret=%s", $user, $hostname, $secret);
    $encoder = "https://chart.googleapis.com/chart?chs=200x200&chld=Q|2&cht=qr&chl=";
    $encoderURL = $encoder . urlencode($url);
    return $encoderURL;
}