Created
March 22, 2011 16:51
-
-
Save iporsut/881555 to your computer and use it in GitHub Desktop.
Crawler class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 />"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
อ่าห์ คงต้องเอาไปลอง จะได้เข้าวจัยโค้ด