function googleCards($plus_id, $credit = 1, $author, $blank)
{
    // include our scraper class
    include_once 'googleCardClass.php';
    // initiate an instance of our scraper class
    $plus = new googleCard($plus_id);
    // if we can use file caching
    if (gc_caching()) {
        $plus->cache_data = 1;
        $plus->cache_file = WP_CONTENT_DIR . "/cache/plus_cards.txt";
    }
    // do the scrape
    $data = $plus->googleCard();
    if (isset($data) && !empty($data['name']) && !empty($data['img'])) {
        // setup rel=author and target=blank options
        $rel = '';
        if (isset($author) && $author > 0) {
            $rel = 'rel="author"';
        } else {
            $rel = '';
        }
        $tab = '';
        if (isset($blank) && $blank > 0) {
            $tab = 'target="_blank"';
        } else {
            $tab = '';
        }
        ?>
		<div id="plus_card">
			<div id="plus_card_image">
				<a <?php 
        echo $rel;
        ?>
 href="<?php 
        echo $data['url'];
        ?>
" <?php 
        echo $tab;
        ?>
>
					<?php 
        echo '<img src="' . $data['img'] . '" width="80" height="80" />';
        ?>
				</a>
			</div>
			<div id="plus_card_name">
				<a <?php 
        echo $rel;
        ?>
 href="<?php 
        echo $data['url'];
        ?>
" <?php 
        echo $tab;
        ?>
><?php 
        echo $data['name'];
        ?>
</a>
			</div>
			<span id="plus_card_add">
				<a <?php 
        echo $rel;
        ?>
 href="<?php 
        echo $data['url'];
        ?>
" <?php 
        echo $tab;
        ?>
>Add to circles</a>
			</span>
			<div id="plusCardCount">
				<p>In <?php 
        if (isset($data['count'])) {
            echo $data['count'];
        } else {
            echo 0;
        }
        ?>
 people's circles</p>
			</div>
			<?php 
        if (isset($credit) && $credit > 0) {
            ?>
			<div id="plusCardCredit">
				<p>Google+ card by <a href="http://plusdevs.com" <?php 
            echo $tab;
            ?>
>plusdevs</a></p>
			</div>
			<span id="plusCardShowHide" onclick="togglePlusCredit()">+i</span>
			<?php 
        }
        ?>
			<?php 
        echo '<!--gcVersion = ' . GOOGLECARD_CURRENT_VERSION . ' -->';
        ?>
		</div>
	<?php 
    } else {
        echo 'Couldn\'t get data from google+';
        echo '<!--gcVersion = ' . GOOGLECARD_CURRENT_VERSION . ' -->';
    }
}
Exemple #2
0
include 'googleCard-Wordpress/googleCardClass.php';
$error = '';
$id = $_GET['id'];
if ($id == '') {
    // no id entered
    $error = 'You didn\'t enter a Google+ id!';
} elseif (!is_numeric($id)) {
    // not a number
    $error = 'The Google+ id you entered (' . $id . ') is not a number!';
} elseif (strlen($id) != 21) {
    // wrong size number
    $error = 'The Google+ id you entered (' . $id . ') has the wrong number of digits.';
} else {
    // get data from google
    $scraper = new googleCard($id);
    $gplus = $scraper->googleCard();
    // make name into array so we can get the first name easily
    $name = explode(' ', $gplus['name']);
    // show follower count and XX.XK if more than 3 digits
    $count = $gplus['count'];
    if ($count > 999) {
        $count = sprintf('%.1fK', $count / 1000);
    }
}
?>
<!DOCTYPE html>
<html>
  <head>
    <title>gfollow</title>
    <link rel="stylesheet" type="text/css" href="buttonstyle.css" />
  </head>