Skip to content

Instantly share code, notes, and snippets.

@bartolsthoorn
Created July 1, 2011 14:50
Show Gist options
  • Save bartolsthoorn/1058700 to your computer and use it in GitHub Desktop.
Save bartolsthoorn/1058700 to your computer and use it in GitHub Desktop.
Retrieving Facebook Wall Posts.
<?php
// FACEBOOK WALL RSS FETCHER
// For ID, request: https://graph.facebook.com/xxyourpagexx
$wall = stealthget("http://www.facebook.com/feeds/page.php?format=atom10&id=96302003265", "http://facebook.com");
?>
<pre>
Wall Characters: <?=strlen($wall)?>
<?php
for($z=1; $z<=appearances($wall, "<entry>"); $z++) :
$entry = @kxml($wall, "entry", $z);
if (!$entry) continue;
$title = kxml($entry, "title");
$link = kaboom($entry, "<link rel=\"alternate\" type=\"text/html\" href=\"", "\" />");
$author = kxml($entry, "author");
$name = kxml($author, "name");
$title = substr($title, 0, 30)."..";
echo $title." posted by ".$name."\n";
endfor;
?>
</pre>
<?php
function kaboom($text, $l, $r, $a=1) {
$parts = explode($l, $text);
$parts = explode($r, $parts[$a]);
return $parts[0];
}
function kxml($text, $tag, $a=1) {
return kaboom($text, "<{$tag}>", "</{$tag}>", $a);
}
function appearances($text, $search) {
return count(explode($search, $text));
}
function stealthget($location, $ref) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Stealth; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
$content = curl_exec($ch);
return $content;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment