Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created March 22, 2011 16:51
Show Gist options
  • Save iporsut/881555 to your computer and use it in GitHub Desktop.
Save iporsut/881555 to your computer and use it in GitHub Desktop.
Crawler class
<?php
class Crawler
{
private $_group_id = '';
private $graph_api = 'https://graph.facebook.com';
public function __construct($group_id) {
$this->_group_id = $group_id;
}
public function getGroup() {
return $this->httpGet($this->graph_api.'/'.$this->_group_id);
}
public function getPost($id) {
}
public function getPosts() {
return $this->httpGet($this->graph_api.'/'.$this->_group_id.'/feed');
}
public function getYesterdayPost() {
return $this->httpGet($this->graph_api.'/'.$this->_group_id.'/feed?since=yesterday&until=today');
}
private function httpGet($url) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
}
$test = new Crawler('161323203888755');
$posts = json_decode($test->getYesterdayPost());
foreach($posts->data as $post) {
echo $post->message."<br />";
}
?>
@phondanai
Copy link

อ่าห์ คงต้องเอาไปลอง จะได้เข้าวจัยโค้ด

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment