Friday, 20 December 2013

PHP - Get Facebook Public Profile Posts

<?php
$access_token = 'APP_ID|APP_SECRET';
$profileURL = "https://graph.facebook.com/puppies/posts?access_token=".$access_token;
$page_posts = json_decode(file_get_contents($profileURL), true);
if(count($page_posts['data'])) { ?>
    <h2>Puppies Profile Public Posts</h2>
    <table>
    <?php foreach($page_posts['data'] as $post){ ?>
        <?php if(isset($post['picture']) && isset($post['link'])) { ?>
            <tr>
                <td><img src="<?php print $post['picture'];?>" style="vertical-align:inherit;"></td>
                <td>
                    <h5>
                        <a href="<?php print $post['link'];?>"><?php print substr($post['message'], 0, 100)."...";?></a>
                    </h5>
                </td>
            </tr>
        <?php }
    } ?>
    </table>
<?php } ?>

RESULT:
 

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.