Abrufen der Liste von Google Fonts

Möchte ich, um die Liste der google web fonts wählen Sie im Feld wählen Sie eine schriftart aus. Ich versuche folgende Funktion, aber es gibt die Fehler.

Code:

function get_google_fonts() {
    $url = "https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha";
    $result = json_response( $url );
        $font_list = array();
        foreach ( $result->items as $font ) {
            $font_list[] .= $font->family;          
        }
        return $font_list;  
}

function json_response( $url )  {
    $raw = file_get_contents( $url, 0, null, null );
    $decoded = json_decode( $raw );
    return $decoded;
}

Fehler:

Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP.

Wenn ich den https-zu-http, bekomme ich diesen Fehler:

file_get_contents(http://www.googleapis.com/webfonts/v1/webfonts?sort=alpha): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in

Ich denke, dies ist aufgrund der PHP-Einstellungen auf meinem server, die ich nicht in der Lage bin zu ändern. Also, gibt es irgendeine alternative Möglichkeit, um die schriftart-Liste von Google? Danke.

InformationsquelleAutor user1251698 | 2012-09-27
Schreibe einen Kommentar