Für mein Blog benutze ich das googleCards Plugin von Majubo.
Leider ändert Goggle im Moment alle paar Tage die Bezeichnung der CSS Klassen, sodass das Plugin jedes Mal angepasst werden muss. Ich habe die Regular Expressions zum Suchen des Profilbildes und des „In X people’s circles“ Elements so angepasst das die GoogleCard mit den Änderungen vom 27.08.2011 wieder korrekt angezeigt wird. Zusätzlich habe ich einen Patch für das PHP-cURL Dualstackproblem hinzugefügt.
--- googleCardClass.php.orig 2011-08-04 16:07:22.000000000 +0200 +++ googleCardClass.php 2011-08-27 16:34:51.000000000 +0200 @@ -5,6 +5,10 @@ * http://plusdevs.com * http://plusdevs.com/googlecard-googleplus-php-scraper/ * +* Modified to match google+ classes from 2011/08/27 (see lines 128, 144) +* Added cURL IPv4 Patch (see line 170) +* Peter Hilbring +* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -121,8 +125,7 @@ protected function parseHtml() { // parse the html to look for the h4 'have X in circles' element - preg_match('/</pre> <h4 class="a-b-Fa-ug">(.*?)/s', $this->html, $matches); - + preg_match('/</h4> <h4 class="nPQ0Mb pD8zNd">(.*?)/s', $this->html, $matches); if (isset($matches) && !empty($matches)) { $count = $matches[1]; @@ -138,12 +141,12 @@ $name = $matches[1]; // parse the html for the img div - preg_match('/</h4> <div class="a-R-Z-z-M">(.*?)/s', $this->html, $matches); + preg_match('/ <div class="DzkbSc">(.*?)/s', $this->html, $matches); $img_div = $matches[1]; // parse the img div for the image src preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $img_div, $matches); - $img = 'http:' . $matches[1]; + $img = 'https:' . $matches[1]; // put the data in an array $return = array('id' => $this->user_id, 'count' => $circles, 'name' => $name, 'img' => $img, 'url' => $this->url); @@ -164,6 +167,7 @@ curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($this->curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // execute the call to google+ $this->html = curl_exec($this->curl); +?>
Zur Inbetriebnahme reicht es aus die Datei „googleCardClass.php“ einfach in das Verzeichnis „wp-content/plugins/googlecards/“ zu kopieren und die vorhandene Datei zu überschreiben. Die eventuell vorhandene Datei „wp-content/cache/plus_cards.txt“ muss auf jeden Fall gelöscht werden.
[attachments title=“Downloads“ force_saveas=“1″ logged_users=“0″]