Exemple #1
0
require_once 'googleplus.class.php';
$arrTests = array('https://plus.google.com/111291152590065605567/posts');
foreach ($arrTests as $strTest) {
    $oGooglePlus = new GooglePlus($strTest);
    if ($oGooglePlus->isReady) {
        $channel = array();
        $channel['title'] = 'Google+ profile of ' . $oGooglePlus->getName();
        $channel['description'] = $oGooglePlus->getIntroduction() . ', ' . $oGooglePlus->getOccupation();
        $channel['link'] = 'https://plus.google.com/' . $oGooglePlus->strProfileId . '/posts';
        $arrPosts = $oGooglePlus->getPosts();
        $arrLinks = $oGooglePlus->getLinks();
        $i = 0;
        $w = new Rss('php://output', $channel['title'], $channel['description'], $channel['link'], date('Y-m-d'));
        foreach ($arrPosts as $strPost) {
            $item = array();
            $item['title'] = $oGooglePlus->getShortText($strPost, 120, TRUE);
            if ($arrLinks[$i]) {
                $item['link'] = 'https://plus.google.com/' . $oGooglePlus->strProfileId . '/posts/' . $arrLinks[$i];
            }
            $item['description'] = $strPost;
            if ($arrLinks[$i]) {
                $item['guid'] = 'https://plus.google.com/' . $oGooglePlus->strProfileId . '/posts/' . $arrLinks[$i];
            }
            //$item['date'] = date('Y-m-d');
            $w->add_item($item);
            $i++;
        }
        $i++;
        $w->end_rss();
    }
}
    // declarer for rss element
    $writer->startElement('rss');
    $writer->writeAttribute('version', '2.0');
    $writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
    // start element channel
    $writer->startElement('channel');
    $writer->writeElement('title', 'Google+ profile of ' . $oGooglePlus->get('name'));
    $writer->writeElement('description', strip_tags($oGooglePlus->get('introduction')));
    $writer->writeElement('link', $oGooglePlus->get('url'));
    $writer->writeElement('pubDate', date('D, d M Y H:i:s e'));
    $writer->endElement();
    // end element channel
    if ($oGooglePlus->get('plainposts') != 'n/A') {
        foreach ($oGooglePlus->get('plainposts') as $arrLink) {
            $writer->startElement('item');
            $writer->writeElement('title', GooglePlus::getShortText($arrLink[0], 120, true));
            $writer->writeElement('description', $arrLink[0]);
            if ($arrLink[1]) {
                $writer->writeElement('link', $arrLink[1]);
                $writer->writeElement('guid', $item['guid'] = $arrLink[1]);
            }
            $writer->endElement();
        }
    }
    // end element channel
    $writer->endElement();
    // End rss element
    $writer->endElement();
    $writer->endDocument();
    $writer->flush();
}
foreach ($arrTests as $strTest) {
    $oGooglePlus = new GooglePlus($strTest);
    if ($oGooglePlus->isReady) {
        echo '<h1>Parsing Google+ profile of “' . $oGooglePlus->get('name') . '”</h1>';
        if (($strDesc = $oGooglePlus->get('description')) && $strDesc != 'n/A') {
            echo '<h2>' . $strDesc . '</h2>';
        }
        echo '<p><img src="' . $oGooglePlus->get('image') . '" width="100" height="100" alt="Profile Image" style="float:right;"></p>';
        echo '<p><b>Google+ id:</b> ' . $oGooglePlus->get('id') . '</p>';
        echo '<p><b>Google+ profile url:</b> <a href="' . $oGooglePlus->get('url') . '">' . $oGooglePlus->get('url') . '</a></p>';
        echo '<p><b>First name:</b> ' . $oGooglePlus->get('firstname') . ' <b>Last name:</b> ' . $oGooglePlus->get('lastname') . ' <b>Nickname:</b> ' . $oGooglePlus->get('nickname') . ' <b>Other names:</b> ' . $oGooglePlus->get('othernames') . '</p>';
        echo '<p><b>Occupation:</b> ' . $oGooglePlus->get('occupation') . '</p>';
        echo '<p><b>Introduction:</b> ' . $oGooglePlus->get('introduction') . '</p>';
        echo '<p><b>Links:</b> ';
        if ($oGooglePlus->get('links') == 'n/A') {
            echo 'n/A';
        } else {
            foreach ($oGooglePlus->get('links') as $arrLink) {
                echo '<a href="' . $arrLink[1] . '">' . $arrLink[0] . '</a> ';
            }
        }
        echo '</p>';
        echo '<p><b>Posts as Plain (max. 200 chars):</b></p>';
        if ($oGooglePlus->get('plainposts') != 'n/A') {
            foreach ($oGooglePlus->get('plainposts') as $arrLink) {
                echo '<p>' . GooglePlus::getShortText($arrLink[0], 200, true) . ' <a href="' . $arrLink[1] . '">Read full post!</a></p>';
            }
        }
        echo '<hr style="clear:right;">';
    }
}
 * @author     Frank Bueltge <*****@*****.**>
 * @copyright  2011 -- Frank Bueltge
 * @license    Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany
 *             (http://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.en)
 * @link       http://bueltge.de
 * @version    1.1
 * @date       10.07.2011 20:11:01
*/
require_once 'rss2.class.php';
require_once 'googleplus.class.php';
$oGooglePlus = new GooglePlus('https://plus.google.com/111291152590065605567/posts');
if ($oGooglePlus->isReady) {
    $channel = array();
    $channel['title'] = 'Google+ profile of ' . $oGooglePlus->get('name');
    $channel['description'] = strip_tags($oGooglePlus->get('introduction'));
    $channel['link'] = $oGooglePlus->get('url');
    $w = new Rss('php://output', $channel['title'], $channel['description'], $channel['link'], date('Y-m-d'));
    if ($oGooglePlus->get('plainposts') != 'n/A') {
        foreach ($oGooglePlus->get('plainposts') as $arrLink) {
            $item = array();
            $item['title'] = GooglePlus::getShortText($arrLink[0], 120, true);
            if ($arrLink[1]) {
                $item['link'] = $arrLink[1];
                $item['guid'] = $arrLink[1];
            }
            $item['description'] = $arrLink[0];
            $w->add_item($item);
        }
    }
    $w->end_rss();
}