コード例 #1
0
 /**
  * GooglePlus constructor.
  *
  * @param string  $strProfile The url/id of the Google+ profile.
  * @param integer $intCache   The maximum age (in minutes) of the cache (default 4 hours).
  */
 public function __construct($strProfile, $intCache = 240)
 {
     // This script requires cURL.
     if (!function_exists('curl_init')) {
         throw new GooglePlusException('cURL not installed. See http://php.net/manual/en/book.curl.php for details.');
     }
     // Check if debug should be enabled or not.
     if (GooglePlus::GPLUS_DEBUG) {
         error_reporting(-1);
         ini_set('display_errors', 1);
     } else {
         error_reporting(0);
         ini_set('display_errors', 0);
     }
     // Set the global cache timeout (fallback to 4 hours if the value is crap).
     $this->_intCache = is_int($intCache) ? $intCache : 240;
     // Fetch the HTML of the page.
     if (!GooglePlus::fetchUrl($strProfile)) {
         //throw new GooglePlusException('Error fetching the HTML of this Google+ profile.');
         echo 'Failed';
     }
 }
コード例 #2
0
 public function getProfileInformation($googlePlusService = false, $oauth2 = false)
 {
     if (!empty($_SESSION['google_plus']['profile_info']) && $_SESSION['sn']['authorized'] === true) {
         self::$oProfile = unserialize($_SESSION['google_plus']['profile_info']);
     } elseif ($googlePlusService && $oauth2) {
         if (self::$object) {
             if (isset($_SESSION['access_token'])) {
                 self::$object->setAccessToken($_SESSION['access_token']);
             }
             if (self::$object->getAccessToken()) {
                 self::$oProfile = $googlePlusService->people->get('me');
                 $userInfo = $oauth2->userinfo->get();
                 self::$oProfile['email'] = $userInfo['email'];
                 $_SESSION['google_plus']['profile_info'] = serialize(self::$oProfile);
             }
         }
     }
     if (self::$oProfile) {
         self::$oSocialPlugin = $this;
     } else {
         unset($_SESSION['google_plus']);
     }
     return self::$oProfile;
 }
コード例 #3
0
ファイル: feed.php プロジェクト: Balamir/GooglePlus-Scraper
/**
 * GooglePlus Feed RSS 2.0
 *
 * @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.0
 * @date       04.07.2011 17:17:29
*/
require_once 'rss2.class.php';
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];
            }
コード例 #4
0
      padding:0;
      margin-bottom:5px;
    }
    hr {
      clear:both;
      margin:20px 0;
    }
  </style>
  <link rel="alternate" type="application/rss+xml" title="G+ Posts RSS 2.0" href="feed.php" />
</head>
<body>
<?php 
require_once 'googleplus.class.php';
$arrTests = array('https://plus.google.com/117918784076966584831/posts', 'https://plus.google.com/107117483540235115863/posts', 'https://plus.google.com/106189723444098348646/posts', 'https://plus.google.com/111091089527727420853/posts', '109813896768294978296', '109412257237874861202');
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 {
コード例 #5
0
<?php

/**
 * Simple GooglePlus-Feed
 *
 * @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:18:01
*/
require_once 'googleplus.class.php';
@date_default_timezone_set('GMT');
$oGooglePlus = new GooglePlus('https://plus.google.com/111291152590065605567/posts');
if ($oGooglePlus->isReady) {
    $writer = new XMLWriter();
    $writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(true);
    // 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'));
コード例 #6
0
 public function testGooglePlus()
 {
     $gplus = new GooglePlus();
     $this->assertEquals('googleplus', $gplus->getKey());
     $this->assertNotNull($gplus->getShareCount(self::TEST_URL));
 }
コード例 #7
0
<?php

/**
 * GooglePlus Feed RSS 2.0
 *
 * @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];