1
1
<?php
2
+ /**
3
+ * A PHP client library for pubsubhubbub
4
+ *
5
+ * @link http://code.google.com/p/pubsubhubbub/
6
+ * @author Josh Fraser | joshfraser.com | josh@eventvue.com
7
+ * @license Apache License 2.0
8
+ */
2
9
3
- // a PHP client library for pubsubhubbub
4
- // as defined at http://code.google.com/p/pubsubhubbub/
5
- // written by Josh Fraser | joshfraser.com | josh@eventvue.com
6
- // Released under Apache License 2.0
10
+ namespace pubsubhubbub /subscriber;
7
11
8
12
class Subscriber {
9
-
10
- // put your google key here
11
- // required if you want to use the google feed API to lookup RSS feeds
13
+ /**
14
+ * put your google key here
15
+ * required if you want to use the google feed API to lookup RSS feeds
16
+ *
17
+ * @var string
18
+ */
12
19
protected $ google_key = "" ;
13
20
21
+ /** @var string */
14
22
protected $ hub_url ;
23
+
24
+ /** @var string */
15
25
protected $ callback_url ;
26
+
27
+ /** @var string */
16
28
protected $ credentials ;
17
- // accepted values are "async" and "sync"
29
+
30
+ /**
31
+ * @var string accepted values are "async" and "sync"
32
+ */
18
33
protected $ verify = "async " ;
34
+
35
+ /** @var string */
19
36
protected $ verify_token ;
37
+
38
+ /** @var int */
20
39
protected $ lease_seconds ;
21
40
22
- // create a new Subscriber (credentials added for SuperFeedr support)
41
+ /**
42
+ * create a new Subscriber (credentials added for SuperFeedr support)
43
+ *
44
+ * @param string $hub_url
45
+ * @param string $callback_url
46
+ * @param string $credentials
47
+ */
23
48
public function __construct ($ hub_url , $ callback_url , $ credentials = false ) {
24
49
25
50
if (!isset ($ hub_url ))
@@ -36,7 +61,13 @@ public function __construct($hub_url, $callback_url, $credentials = false) {
36
61
$ this ->credentials = $ credentials ;
37
62
}
38
63
39
- // $use_regexp lets you choose whether to use google AJAX feed api (faster, but cached) or a regexp to read from site
64
+ /**
65
+ * $use_regexp lets you choose whether to use google AJAX feed api (faster, but cached) or a regexp to read from site
66
+ *
67
+ * @param string $url
68
+ * @param callable $http_function
69
+ * @return string
70
+ */
40
71
public function find_feed ($ url , $ http_function = false ) {
41
72
// using google feed API
42
73
$ url = "http://ajax.googleapis.com/ajax/services/feed/lookup?key= {$ this ->google_key }&v=1.0&q= " .urlencode ($ url );
@@ -51,15 +82,32 @@ public function find_feed($url, $http_function = false) {
51
82
return $ rss_url ;
52
83
}
53
84
85
+ /**
86
+ * @param string $topic_url
87
+ * @param callable $http_function
88
+ * @return mixed
89
+ */
54
90
public function subscribe ($ topic_url , $ http_function = false ) {
55
91
return $ this ->change_subscription ("subscribe " , $ topic_url , $ http_function = false );
56
92
}
57
93
94
+ /**
95
+ * @param string $topic_url
96
+ * @param callable $http_function
97
+ * @return mixed
98
+ */
58
99
public function unsubscribe ($ topic_url , $ http_function = false ) {
59
100
return $ this ->change_subscription ("unsubscribe " , $ topic_url , $ http_function = false );
60
101
}
61
102
62
- // helper function since sub/unsub are handled the same way
103
+ /**
104
+ * helper function since sub/unsub are handled the same way
105
+ *
106
+ * @param string $mode
107
+ * @param string $topic_url
108
+ * @param callable $http_function
109
+ * @return mixed
110
+ */
63
111
private function change_subscription ($ mode , $ topic_url , $ http_function = false ) {
64
112
if (!isset ($ topic_url ))
65
113
throw new Exception ('Please specify a topic url ' );
@@ -86,7 +134,13 @@ private function change_subscription($mode, $topic_url, $http_function = false)
86
134
return $ this ->http ($ this ->hub_url ,$ post_string );
87
135
}
88
136
89
- // default http function that uses curl to post to the hub endpoint
137
+ /**
138
+ * default http function that uses curl to post to the hub endpoint
139
+ *
140
+ * @param string $url
141
+ * @param string $post_string
142
+ * @return mixed
143
+ */
90
144
private function http ($ url , $ post_string ) {
91
145
92
146
// add any additional curl options here
@@ -115,6 +169,3 @@ private function http($url, $post_string) {
115
169
return false ;
116
170
}
117
171
}
118
-
119
-
120
- ?>
0 commit comments