PHP Script To Check Social Signals

Thought I would share this, may be of use to some of you. Quick & dirty PHP script I wrote that parses an RSS feed & displays Facebook signals one one page.

I use this to verify that MP is liking / sharing everything my accounts post on Facebook. If anything looks out of whack, I use the embedded browser to load this page with each of my accounts & then manually like / share the posts.

You should be able to tweak this for Twitter / Pinterest / whatever.

Sample Output:

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php require_once "functions.php"; ?>
<div>

    <div>
 
        <div>
            <h3>SITE 1</h3>
        </div>
        <div>
            <?php getFeed("http://site1/feed"); ?>
        </div>

        <div>
            <h3>SITE 2</h3>
        </div> 
        <div>
            <?php getFeed("http://site2/feed"); ?>
        </div>
 
    </div>
</body>
</html>

functions.php

<?php
 
function getFeed($feed_url) {
     
    $content = file_get_contents($feed_url);
    $x = new SimpleXmlElement($content);
     
    foreach($x->channel->item as $entry) {
        echo "<div class='fb-like' data-href='$entry->link' data-layout='standard' data-action='like' data-size='small' data-show-faces='true' data-share='true'></div>";
    }
}
?>
3 Likes

Good one. Thanks for sharing

Very nice share @trolling4dollars maybe a few usage/installation instructions if you have the time, it would help members make the most of it.

Super simple to use.

I’d suggest creating a subdirectory on your web server - for instance, “signals”. Create the index.php & functions.php files & copy / paste the code.

Only change, change this URL in index.php to the RSS address of your blog. If it’s wordpress, it will be http://sitename.com/feed

Assuming you created a “signals” directory on your server, just go to http://sitename.com/signals/ & everything will magically appear.

1 Like

That’s perfect :smiley: cause everybody likes magic :star2:

Hey @trolling4dollars,

I have a imacros set up doing some auto scrolling on some site via chrome. Some time it would stop/crash do you think a script like that would work for me where it send me an alert every time that happen?