-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFeed.php
More file actions
80 lines (70 loc) · 1.92 KB
/
Feed.php
File metadata and controls
80 lines (70 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php //-->
/*
* This file is part of the Utility package of the Eden PHP Library.
* (c) 2013-2014 Openovate Labs
*
* Copyright and license information can be found at LICENSE
* distributed with this package.
*/
namespace Eden\Facebook;
use Eden\Curl\Base as Curl;
/**
* Facebook Page Feed
*
* @vendor Eden
* @package Facebook
* @author Ian Mark Muninio <ianmuninio@opengate.com>
*/
class Feed extends Base
{
const RSS_FORMAT = 'rss20';
const JSON_FORMAT = 'json';
const FEED_URL = 'https://www.facebook.com/feeds/page.php?id=%s&format=%s';
const USER_AGENT = 'facebook-php-eden';
protected $id = null;
/**
* Sets the id of the page.
*
* @param int $id
* @return void
*/
public function __construct($id)
{
Argument::i()->test(1, 'number');
$this->id = $id;
}
/**
* Returns the SimpleXML Format feed of the page.
*
* @return \SimpleXMLElement the feed of the page on xml format
*/
public function getRss()
{
$results = Curl::i()
->setUrl(sprintf(self::FEED_URL, $this->id, self::RSS_FORMAT))
->setUserAgent(self::USER_AGENT)
->setConnectTimeout(10)
->setFollowLocation(true)
->setTimeout(60)
->verifyPeer(false)
->getSimpleXmlResponse();
return $results;
}
/**
* Returns the JSON format feed of the page.
*
* @return array the feed of the page on json format
*/
public function getJson()
{
$results = Curl::i()
->setUrl(sprintf(self::FEED_URL, $this->id, self::JSON_FORMAT))
->setUserAgent(self::USER_AGENT)
->setConnectTimeout(10)
->setFollowLocation(true)
->setTimeout(60)
->verifyPeer(false)
->getJsonResponse();
return $results;
}
}