-
Notifications
You must be signed in to change notification settings - Fork 7
/
subscribe.php
54 lines (42 loc) · 1.36 KB
/
subscribe.php
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
<?php
$_SERVER['HTTP_HOST'] = 'v1.chregu.tv';
define("R2T_PROJECT_DIR",dirname(__FILE__));
ini_set("include_path",R2T_PROJECT_DIR."/inc/:/var/www/zf-trunk/:".ini_get("include_path"));
require_once 'Zend/Feed/Reader.php';
//$topic = 'http://chregu.tv/blog/atom.xml';
$topic = 'http://www.planet-php.net/atom/';
$feed = Zend_Feed_Reader::import($topic);
$feedTopicUri = $feed->getFeedLink();
/**
* The feed may advertise one or more Hub Endpoints we can use.
* We may subscribe to the Topic using one or more of the Hub
* Endpoints advertised (good idea in case a Hub goes down).
*/
$feedHubs = $feed->getHubs();
/**
* Carry out subscription operation...
*/
require_once( "Zend/Feed/Pubsubhubbub/Storage/Filesystem.php");
$storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem;
$storage->setDirectory(R2T_PROJECT_DIR."/tmp");
$options = array(
'topicUrl' => $feedTopicUri,
'hubUrls' => $feedHubs,
'storage' => $storage,
'callbackUrl' => 'http://'.$_SERVER['HTTP_HOST'].'/rss2twi/callback.php',
'usePathParameter' => true,
'authentications' => array(
)
);
require_once( "Zend/Feed/Pubsubhubbub/Subscriber.php");
$subscriber = new Zend_Feed_Pubsubhubbub_Subscriber($options);
$subscriber->subscribeAll();
/**
* Do some checking for errors...
*/
if (!$subscriber->isSuccess()) {
var_dump($subscriber->getErrors()); exit;
print "<br/>ERROR";
} else {
error_log("SEEMS TO BE OK");
}