开发者

Facebook API / httpclient wrapper for crawling through the wall posts & group posts of any user?

开发者 https://www.devze.com 2023-01-23 14:24 出处:网络
I am completely new to facebook api and working on a very small project. Before getting into details of their api doc, I wanted to ask a quick question.

I am completely new to facebook api and working on a very small project. Before getting into details of their api doc, I wanted to ask a quick question.

My application needs login with a facebook userid/passwo开发者_如何学Crd, go to a friends wall / groups wall, crawl through all the wall posts and dump them in database for further analysis. A simple http client would do the trick if facebook weren't completely unusable without javascript. Since its going to be a desktop app, I am reluctant to go for a full fledged server based app.

So what should be the simplest way of crawling through FB friend / group wall? Please correct me if I'm asking the wrong question because I have Zero FB knowledge.

PS: I would like a java based library / wrapper but any language would do...


the current api has some serious bugs. Either you only get 50 items from the wall or only the items of the last 30 days, which comes first.

Please check the facebook developer bug list first. Developer Bug list


The Facebook Graph API would be the best solution, but if it is buggy, as Herr Kaleun pointed out, and you need more than 50 items or 30 days of posts, then I have another idea.

It may not satisfy your distribution requirements, but if it does you can implement this as a GreaseMonkey user script. GreaseMonkey is a system for web client automation that is javascript-aware. It lives in the web browser and is written and controlled by javascript, and can also pragmatically simulate a user affecting javascript. GreaseMonkey is a Firefox plugin, but Chrome also has native support for user scripts (the language is slightly different, but most GreaseMonkey user scripts will work in Chrome).


Ok, on a quick search, It seems that the answer is the FB Graph API. I can see there are wrappers of graph api in almost all language. For Java, I found the RestFB & BatchFB. Please feel free to refer to any more useful / advanced api if available.

UPDATE:

I couldn't find any extended permission set to access a user's group wall / a user's friends wall? is it atall possible with an Application?


Prerequisites:

Your group needs to be publicly viewable You need to have signed up to make a Facebook app, in order to get the APP_ID AND SECRET_KEY.

Then, (example in PHP, but should easily be transposed to another language):

$url =
"https://graph.facebook.com/{$group_id}/feed?access_token=APP_ID|SECRET_KEY";

$data = json_decode(file_get_contents($url));

foreach($data->data as $d)
{
   ?>
   <div>
    <a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
    <img border="0" alt="<?=$d->from->name?>"
        src="https://graph.facebook.com/<?=$d->from->id?>/picture"/>
    </a>
   </div>
   <div>
    <a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
    <?=$d->from->name?></a>
    on <?=date('F j, Y H:i',strtotime($d->created_time))?>
    <br/>
    <?=$d->message?>
  </div>
</div>
<?
}

This will get the wall posts. As far as limits, I don't know.

0

精彩评论

暂无评论...
验证码 换一张
取 消