Get data from a facebook page wall or group wall for use on personal website

前端 未结 4 1371
遥遥无期
遥遥无期 2021-01-31 06:14

I want to connect to public facebook page or group and list all entries from the wall on a personal website. I will use PHP on my server so that would be the best solution for m

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 06:34

    What you are talking about, as far as I can tell, is Web Scraping. What you would do is get the URL of the group, use the file_get_contents($url) command in PHP to get the file, and then analyze it in PHP.

    I'd suggest brushing up on your regular expressions for this, as it'll be important to review the HTML that Facebook uses for the wall posts. You'll be able to get the information that you're looking for from the HTML.

    I would post some example code, but that's on another computer, far far away. Still, should be a good start.

    Edit: Adding in some example code:

     $URL = "http://facebook.com/group=5343242" (or whatever the URL structure is for the facebook group)
    $groupPage = file_get_contents($URL)
    

    Here's the link to the PHP pages on Regular Expressions:

    http://www.php.net/manual/en/book.pcre.php

提交回复
热议问题