]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/ActivityParseTests.php
Remove CSRF protection from username/password login and from OpenID login.
[quix0rs-gnu-social.git] / tests / ActivityParseTests.php
1 <?php
2
3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4     print "This script must be run from the command line\n";
5     exit();
6 }
7
8 // XXX: we should probably have some common source for this stuff
9
10 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
11 define('STATUSNET', true);
12
13 require_once INSTALLDIR . '/lib/common.php';
14
15 class ActivityParseTests extends PHPUnit_Framework_TestCase
16 {
17     public function testExample1()
18     {
19         global $_example1;
20         $dom = DOMDocument::loadXML($_example1);
21         $act = new Activity($dom->documentElement);
22
23         $this->assertFalse(empty($act));
24
25         $this->assertEquals(1243860840, $act->time);
26         $this->assertEquals(ActivityVerb::POST, $act->verb);
27
28         $this->assertFalse(empty($act->objects[0]));
29         $this->assertEquals('Punctuation Changeset', $act->objects[0]->title);
30         $this->assertEquals('http://versioncentral.example.org/activity/changeset', $act->objects[0]->type);
31         $this->assertEquals('Fixing punctuation because it makes it more readable.', $act->objects[0]->summary);
32         $this->assertEquals('tag:versioncentral.example.org,2009:/change/1643245', $act->objects[0]->id);
33     }
34
35     public function testExample2()
36     {
37         global $_example2;
38         $dom = DOMDocument::loadXML($_example2);
39         $act = new Activity($dom->documentElement);
40
41         $this->assertFalse(empty($act));
42         // Did we handle <content type="html"> correctly with a typical payload?
43         $this->assertEquals("<p>Geraldine posted a Photo on PhotoPanic</p>\n     " .
44                             "<img src=\"/geraldine/photo1.jpg\">", trim($act->content));
45     }
46
47     public function testExample3()
48     {
49         global $_example3;
50         $dom = DOMDocument::loadXML($_example3);
51
52         $feed = $dom->documentElement;
53
54         $entries = $feed->getElementsByTagName('entry');
55
56         $entry = $entries->item(0);
57
58         $act = new Activity($entry, $feed);
59
60         $this->assertFalse(empty($act));
61         $this->assertEquals(1071340202, $act->time);
62         $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->link);
63
64         $this->assertEquals($act->verb, ActivityVerb::POST);
65
66         $this->assertFalse(empty($act->actor));
67         $this->assertEquals(ActivityObject::PERSON, $act->actor->type);
68         $this->assertEquals('John Doe', $act->actor->title);
69         $this->assertEquals('mailto:johndoe@example.com', $act->actor->id);
70
71         $this->assertFalse(empty($act->objects[0]));
72         $this->assertEquals(ActivityObject::NOTE, $act->objects[0]->type);
73         $this->assertEquals('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $act->objects[0]->id);
74         $this->assertEquals('Atom-Powered Robots Run Amok', $act->objects[0]->title);
75         $this->assertEquals('Some text.', $act->objects[0]->summary);
76         $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->objects[0]->link);
77
78         $this->assertFalse(empty($act->context));
79
80         $this->assertTrue(empty($act->target));
81
82         $this->assertEquals($act->entry, $entry);
83         $this->assertEquals($act->feed, $feed);
84     }
85
86     public function testExample4()
87     {
88         global $_example4;
89         $dom = DOMDocument::loadXML($_example4);
90
91         $entry = $dom->documentElement;
92
93         $act = new Activity($entry);
94
95         $this->assertFalse(empty($act));
96         $this->assertEquals(1266547958, $act->time);
97         $this->assertEquals('http://example.net/notice/14', $act->link);
98
99         $this->assertFalse(empty($act->context));
100         $this->assertEquals('http://example.net/notice/12', $act->context->replyToID);
101         $this->assertEquals('http://example.net/notice/12', $act->context->replyToUrl);
102         $this->assertEquals('http://example.net/conversation/11', $act->context->conversation);
103         $this->assertEquals(array('http://example.net/user/1'), $act->context->attention);
104
105         $this->assertFalse(empty($act->objects[0]));
106         $this->assertEquals($act->objects[0]->content,
107                             '@<span class="vcard"><a href="http://example.net/user/1" class="url"><span class="fn nickname">evan</span></a></span> now is the time for all good men to come to the aid of their country. #<span class="tag"><a href="http://example.net/tag/thetime" rel="tag">thetime</a></span>');
108
109         $this->assertFalse(empty($act->actor));
110     }
111
112     public function testExample5()
113     {
114         global $_example5;
115         $dom = DOMDocument::loadXML($_example5);
116
117         $feed = $dom->documentElement;
118
119         // @todo Test feed elements
120
121         $entries = $feed->getElementsByTagName('entry');
122         $entry = $entries->item(0);
123
124         $act = new Activity($entry, $feed);
125
126         // Post
127         $this->assertEquals($act->verb, ActivityVerb::POST);
128         $this->assertFalse(empty($act->context));
129
130         // Actor w/Portable Contacts stuff
131         $this->assertFalse(empty($act->actor));
132         $this->assertEquals($act->actor->type, ActivityObject::PERSON);
133         $this->assertEquals($act->actor->title, 'Test User');
134         $this->assertEquals($act->actor->id, 'http://example.net/mysite/user/3');
135         $this->assertEquals($act->actor->link, 'http://example.net/mysite/testuser');
136
137         $avatars = $act->actor->avatarLinks;
138
139         $this->assertEquals(
140                 $avatars[0]->url,
141                 'http://example.net/mysite/avatar/3-96-20100224004207.jpeg'
142         );
143
144         $this->assertEquals($act->actor->displayName, 'Test User');
145
146         $poco = $act->actor->poco;
147         $this->assertEquals($poco->preferredUsername, 'testuser');
148         $this->assertEquals($poco->address->formatted, 'San Francisco, CA');
149         $this->assertEquals($poco->urls[0]->type, 'homepage');
150         $this->assertEquals($poco->urls[0]->value, 'http://example.com/blog.html');
151         $this->assertEquals($poco->urls[0]->primary, 'true');
152         $this->assertEquals($act->actor->geopoint, '37.7749295 -122.4194155');
153     }
154
155     public function testExample6()
156     {
157         global $_example6;
158
159         $dom = DOMDocument::loadXML($_example6);
160
161         $rss = $dom->documentElement;
162
163         $channels = $dom->getElementsByTagName('channel');
164
165         $channel = $channels->item(0);
166
167         $items = $channel->getElementsByTagName('item');
168
169         $item = $items->item(0);
170
171         $act = new Activity($item, $channel);
172
173         $this->assertEquals($act->verb, ActivityVerb::POST);
174
175         $this->assertEquals($act->id, 'http://en.blog.wordpress.com/?p=3857');
176         $this->assertEquals($act->link, 'http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/');
177         $this->assertEquals($act->title, 'Rub-a-Dub-Dub in the PubSubHubbub');
178         $this->assertEquals($act->time, 1267634892);
179
180         $actor = $act->actor;
181
182         $this->assertFalse(empty($actor));
183         $this->assertEquals($actor->title, "Joseph Scott");
184     }
185
186     public function testExample7()
187     {
188         global $_example7;
189
190         $dom = DOMDocument::loadXML($_example7);
191
192         $rss = $dom->documentElement;
193
194         $channels = $dom->getElementsByTagName('channel');
195
196         $channel = $channels->item(0);
197
198         $items = $channel->getElementsByTagName('item');
199
200         $item = $items->item(0);
201
202         $act = new Activity($item, $channel);
203
204         $this->assertEquals(ActivityVerb::POST, $act->verb);
205         $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->link);
206         $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->id);
207         $this->assertEquals('Checking out captain bones', $act->title);
208         $this->assertEquals(1269095551, $act->time);
209
210         $actor = $act->actor;
211
212         $this->assertEquals(ActivityObject::PERSON, $actor->type);
213         $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->id);
214         $this->assertEquals('Evan Prodromou', $actor->title);
215         $this->assertNull($actor->summary);
216         $this->assertNull($actor->content);
217         $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->link);
218         $this->assertNull($actor->source);
219         $this->assertTrue(is_array($actor->avatarLinks));
220         $this->assertEquals(1, count($actor->avatarLinks));
221         $this->assertEquals('http://files.posterous.com/user_profile_pics/480326/2009-08-05-142447.jpg',
222                             $actor->avatarLinks[0]->url);
223         $this->assertNotNull($actor->poco);
224         $this->assertEquals('evanpro', $actor->poco->preferredUsername);
225         $this->assertEquals('Evan Prodromou', $actor->poco->displayName);
226         $this->assertNull($actor->poco->note);
227         $this->assertNull($actor->poco->address);
228         $this->assertEquals(0, count($actor->poco->urls));
229     }
230
231     // Media test - cliqset
232     public function testExample8()
233     {
234         global $_example8;
235         $dom = DOMDocument::loadXML($_example8);
236
237         $feed = $dom->documentElement;
238
239         $entries = $feed->getElementsByTagName('entry');
240
241         $entry = $entries->item(0);
242
243         $act = new Activity($entry, $feed);
244
245         $this->assertFalse(empty($act));
246         $this->assertEquals($act->time, 1269221753);
247         $this->assertEquals($act->verb, ActivityVerb::POST);
248         $this->assertEquals($act->summary, 'zcopley posted 5 photos on Flickr');
249
250         $this->assertFalse(empty($act->objects));
251         $this->assertEquals(sizeof($act->objects), 5);
252
253         $this->assertEquals($act->objects[0]->type, ActivityObject::PHOTO);
254         $this->assertEquals($act->objects[0]->title, 'IMG_1368');
255         $this->assertNull($act->objects[0]->description);
256         $this->assertEquals(
257             $act->objects[0]->thumbnail,
258             'http://media.cliqset.com/6f6fbee9d7dfbffc73b6ef626275eb5f_thumb.jpg'
259         );
260         $this->assertEquals(
261             $act->objects[0]->link,
262             'http://www.flickr.com/photos/zcopley/4452933806/'
263         );
264
265         $this->assertEquals($act->objects[1]->type, ActivityObject::PHOTO);
266         $this->assertEquals($act->objects[1]->title, 'IMG_1365');
267         $this->assertNull($act->objects[1]->description);
268         $this->assertEquals(
269             $act->objects[1]->thumbnail,
270             'http://media.cliqset.com/b8f3932cd0bba1b27f7c8b3ef986915e_thumb.jpg'
271         );
272         $this->assertEquals(
273             $act->objects[1]->link,
274             'http://www.flickr.com/photos/zcopley/4442630390/'
275         );
276
277         $this->assertEquals($act->objects[2]->type, ActivityObject::PHOTO);
278         $this->assertEquals($act->objects[2]->title, 'Classic');
279         $this->assertEquals(
280             $act->objects[2]->description,
281             '-Powered by pikchur.com/n0u'
282         );
283         $this->assertEquals(
284             $act->objects[2]->thumbnail,
285             'http://media.cliqset.com/fc54c15f850b7a9a8efa644087a48c91_thumb.jpg'
286         );
287         $this->assertEquals(
288             $act->objects[2]->link,
289             'http://www.flickr.com/photos/zcopley/4430754103/'
290         );
291
292         $this->assertEquals($act->objects[3]->type, ActivityObject::PHOTO);
293         $this->assertEquals($act->objects[3]->title, 'IMG_1363');
294         $this->assertNull($act->objects[3]->description);
295
296         $this->assertEquals(
297             $act->objects[3]->thumbnail,
298             'http://media.cliqset.com/4b1d307c9217e2114391a8b229d612cb_thumb.jpg'
299         );
300         $this->assertEquals(
301             $act->objects[3]->link,
302             'http://www.flickr.com/photos/zcopley/4416969717/'
303         );
304
305         $this->assertEquals($act->objects[4]->type, ActivityObject::PHOTO);
306         $this->assertEquals($act->objects[4]->title, 'IMG_1361');
307         $this->assertNull($act->objects[4]->description);
308
309         $this->assertEquals(
310             $act->objects[4]->thumbnail,
311             'http://media.cliqset.com/23d9b4b96b286e0347d36052f22f6e60_thumb.jpg'
312         );
313         $this->assertEquals(
314             $act->objects[4]->link,
315             'http://www.flickr.com/photos/zcopley/4417734232/'
316         );
317
318     }
319
320     public function testAtomContent()
321     {
322         $tests = array(array("<content>Some regular plain text.</content>",
323                              "Some regular plain text."),
324                        array("<content>&lt;b&gt;this is not HTML&lt;/b&gt;</content>",
325                              "&lt;b&gt;this is not HTML&lt;/b&gt;"),
326                        array("<content type='html'>Some regular plain HTML.</content>",
327                              "Some regular plain HTML."),
328                        array("<content type='html'>&lt;b&gt;this is too HTML&lt;/b&gt;</content>",
329                              "<b>this is too HTML</b>"),
330                        array("<content type='html'>&amp;lt;b&amp;gt;but this is not HTML!&amp;lt;/b&amp;gt;</content>",
331                              "&lt;b&gt;but this is not HTML!&lt;/b&gt;"),
332                        array("<content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>Some regular plain XHTML.</div></content>",
333                              "Some regular plain XHTML."),
334                        array("<content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'><b>This is some XHTML!</b></div></content>",
335                              "<b>This is some XHTML!</b>"),
336                        array("<content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>&lt;b&gt;This is not some XHTML!&lt;/b&gt;</div></content>",
337                              "&lt;b&gt;This is not some XHTML!&lt;/b&gt;"),
338                        array("<content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>&amp;lt;b&amp;gt;This is not some XHTML either!&amp;lt;/b&amp;gt;</div></content>",
339                              "&amp;lt;b&amp;gt;This is not some XHTML either!&amp;lt;/b&amp;gt;"));
340         foreach ($tests as $data) {
341             list($source, $output) = $data;
342             $xml = "<entry xmlns='http://www.w3.org/2005/Atom'>" .
343                    "<id>http://example.com/fakeid</id>" .
344                    "<author><name>Test</name></author>" .
345                    "<title>Atom content tests</title>" .
346                    $source .
347                    "</entry>";
348             $dom = DOMDocument::loadXML($xml);
349             $act = new Activity($dom->documentElement);
350
351             $this->assertFalse(empty($act));
352             $this->assertEquals($output, trim($act->content));
353         }
354     }
355
356     public function testRssContent()
357     {
358         $tests = array(array("<content:encoded>Some regular plain HTML.</content:encoded>",
359                              "Some regular plain HTML."),
360                        array("<content:encoded>Some &lt;b&gt;exciting bold HTML&lt;/b&gt;</content:encoded>",
361                              "Some <b>exciting bold HTML</b>"),
362                        array("<content:encoded>Some &amp;lt;b&amp;gt;escaped non-HTML.&amp;lt;/b&amp;gt;</content:encoded>",
363                              "Some &lt;b&gt;escaped non-HTML.&lt;/b&gt;"),
364                        array("<description>Some plain text.</description>",
365                              "Some plain text."),
366                        array("<description>Some &lt;b&gt;non-HTML text&lt;/b&gt;</description>",
367                              "Some &lt;b&gt;non-HTML text&lt;/b&gt;"),
368                        array("<description>Some &amp;lt;b&amp;gt;double-escaped text&amp;lt;/b&amp;gt;</description>",
369                              "Some &amp;lt;b&amp;gt;double-escaped text&amp;lt;/b&amp;gt;"));
370         foreach ($tests as $data) {
371             list($source, $output) = $data;
372             $xml = "<item xmlns:content='http://purl.org/rss/1.0/modules/content/'>" .
373                    "<guid>http://example.com/fakeid</guid>" .
374                    "<title>RSS content tests</title>" .
375                    $source .
376                    "</item>";
377             $dom = DOMDocument::loadXML($xml);
378             $act = new Activity($dom->documentElement);
379
380             $this->assertFalse(empty($act));
381             $this->assertEquals($output, trim($act->content));
382         }
383     }
384
385 }
386
387 $_example1 = <<<EXAMPLE1
388 <?xml version='1.0' encoding='UTF-8'?>
389 <entry xmlns='http://www.w3.org/2005/Atom' xmlns:activity='http://activitystrea.ms/spec/1.0/'>
390   <id>tag:versioncentral.example.org,2009:/commit/1643245</id>
391   <published>2009-06-01T12:54:00Z</published>
392   <title>Geraldine committed a change to yate</title>
393   <content type="xhtml">Geraldine just committed a change to yate on VersionCentral</content>
394   <link rel="alternate" type="text/html"
395         href="http://versioncentral.example.org/geraldine/yate/commit/1643245" />
396   <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
397   <activity:verb>http://versioncentral.example.org/activity/commit</activity:verb>
398   <activity:object>
399     <activity:object-type>http://versioncentral.example.org/activity/changeset</activity:object-type>
400     <id>tag:versioncentral.example.org,2009:/change/1643245</id>
401     <title>Punctuation Changeset</title>
402     <summary>Fixing punctuation because it makes it more readable.</summary>
403     <link rel="alternate" type="text/html" href="..." />
404   </activity:object>
405 </entry>
406 EXAMPLE1;
407
408 $_example2 = <<<EXAMPLE2
409 <?xml version='1.0' encoding='UTF-8'?>
410 <entry xmlns='http://www.w3.org/2005/Atom' xmlns:activity='http://activitystrea.ms/spec/1.0/'>
411   <id>tag:photopanic.example.com,2008:activity01</id>
412   <title>Geraldine posted a Photo on PhotoPanic</title>
413   <published>2008-11-02T15:29:00Z</published>
414   <link rel="alternate" type="text/html" href="/geraldine/activities/1" />
415   <activity:verb>
416   http://activitystrea.ms/schema/1.0/post
417   </activity:verb>
418   <activity:object>
419     <id>tag:photopanic.example.com,2008:photo01</id>
420     <title>My Cat</title>
421     <published>2008-11-02T15:29:00Z</published>
422     <link rel="alternate" type="text/html" href="/geraldine/photos/1" />
423     <activity:object-type>
424       tag:atomactivity.example.com,2008:photo
425     </activity:object-type>
426     <source>
427       <title>Geraldine's Photos</title>
428       <link rel="self" type="application/atom+xml" href="/geraldine/photofeed.xml" />
429       <link rel="alternate" type="text/html" href="/geraldine/" />
430     </source>
431   </activity:object>
432   <content type="html">
433      &lt;p&gt;Geraldine posted a Photo on PhotoPanic&lt;/p&gt;
434      &lt;img src="/geraldine/photo1.jpg"&gt;
435   </content>
436 </entry>
437 EXAMPLE2;
438
439 $_example3 = <<<EXAMPLE3
440 <?xml version="1.0" encoding="utf-8"?>
441
442 <feed xmlns="http://www.w3.org/2005/Atom">
443
444     <title>Example Feed</title>
445     <subtitle>A subtitle.</subtitle>
446     <link href="http://example.org/feed/" rel="self" />
447     <link href="http://example.org/" />
448     <id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
449     <updated>2003-12-13T18:30:02Z</updated>
450     <author>
451         <name>John Doe</name>
452         <email>johndoe@example.com</email>
453     </author>
454
455     <entry>
456         <title>Atom-Powered Robots Run Amok</title>
457         <link href="http://example.org/2003/12/13/atom03" />
458         <link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
459         <link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
460         <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
461         <updated>2003-12-13T18:30:02Z</updated>
462         <summary>Some text.</summary>
463     </entry>
464
465 </feed>
466 EXAMPLE3;
467
468 $_example4 = <<<EXAMPLE4
469 <?xml version='1.0' encoding='UTF-8'?>
470 <entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:ostatus="http://ostatus.org/schema/1.0">
471  <title>@evan now is the time for all good men to come to the aid of their country. #thetime</title>
472  <summary>@evan now is the time for all good men to come to the aid of their country. #thetime</summary>
473 <author>
474  <name>spock</name>
475  <uri>http://example.net/user/2</uri>
476 </author>
477 <activity:actor>
478  <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
479  <id>http://example.net/user/2</id>
480  <title>spock</title>
481  <link type="image/png" rel="avatar" href="http://example.net/theme/identica/default-avatar-profile.png"></link>
482 </activity:actor>
483  <link rel="alternate" type="text/html" href="http://example.net/notice/14"/>
484  <id>http://example.net/notice/14</id>
485  <published>2010-02-19T02:52:38+00:00</published>
486  <updated>2010-02-19T02:52:38+00:00</updated>
487  <link rel="related" href="http://example.net/notice/12"/>
488  <thr:in-reply-to ref="http://example.net/notice/12" href="http://example.net/notice/12"></thr:in-reply-to>
489  <link rel="ostatus:conversation" href="http://example.net/conversation/11"/>
490  <link rel="ostatus:attention" href="http://example.net/user/1"/>
491  <content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://example.net/user/1&quot; class=&quot;url&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;evan&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; now is the time for all good men to come to the aid of their country. #&lt;span class=&quot;tag&quot;&gt;&lt;a href=&quot;http://example.net/tag/thetime&quot; rel=&quot;tag&quot;&gt;thetime&lt;/a&gt;&lt;/span&gt;</content>
492  <category term="thetime"></category>
493 </entry>
494 EXAMPLE4;
495
496 $_example5 = <<<EXAMPLE5
497 <?xml version="1.0" encoding="UTF-8"?>
498 <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0">
499  <id>3</id>
500  <title>testuser timeline</title>
501  <subtitle>Updates from testuser on Zach Dev!</subtitle>
502  <logo>http://example.net/mysite/avatar/3-96-20100224004207.jpeg</logo>
503  <updated>2010-02-24T06:38:49+00:00</updated>
504 <author>
505  <name>testuser</name>
506  <uri>http://example.net/mysite/user/3</uri>
507
508 </author>
509  <link href="http://example.net/mysite/testuser" rel="alternate" type="text/html"/>
510  <link href="http://example.net/mysite/api/statuses/user_timeline/3.atom" rel="self" type="application/atom+xml"/>
511  <link href="http://example.net/mysite/main/sup#3" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
512  <link href="http://example.net/mysite/main/push/hub" rel="hub"/>
513  <link href="http://example.net/mysite/main/salmon/user/3" rel="salmon"/>
514 <activity:subject>
515  <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
516  <id>http://example.net/mysite/user/3</id>
517  <title>Test User</title>
518  <link rel="alternate" type="text/html" href="http://example.net/mysite/testuser"/>
519  <link type="image/jpeg" rel="avatar" href="http://example.net/mysite/avatar/3-96-20100224004207.jpeg"/>
520  <georss:point>37.7749295 -122.4194155</georss:point>
521
522 <poco:preferredUsername>testuser</poco:preferredUsername>
523 <poco:displayName>Test User</poco:displayName>
524 <poco:note>Just another test user.</poco:note>
525 <poco:address>
526  <poco:formatted>San Francisco, CA</poco:formatted>
527 </poco:address>
528 <poco:urls>
529  <poco:type>homepage</poco:type>
530  <poco:value>http://example.com/blog.html</poco:value>
531  <poco:primary>true</poco:primary>
532
533 </poco:urls>
534 </activity:subject>
535 <entry>
536  <title>Hey man, is that Freedom Code?! #freedom #hippy</title>
537  <summary>Hey man, is that Freedom Code?! #freedom #hippy</summary>
538 <author>
539  <name>testuser</name>
540  <uri>http://example.net/mysite/user/3</uri>
541 </author>
542 <activity:actor>
543  <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
544  <id>http://example.net/mysite/user/3</id>
545  <title>Test User</title>
546  <link rel="alternate" type="text/html" href="http://example.net/mysite/testuser"/>
547  <link type="image/jpeg" rel="avatar" href="http://example.net/mysite/avatar/3-96-20100224004207.jpeg"/>
548  <georss:point>37.7749295 -122.4194155</georss:point>
549
550 <poco:preferredUsername>testuser</poco:preferredUsername>
551 <poco:displayName>Test User</poco:displayName>
552 <poco:note>Just another test user.</poco:note>
553 <poco:address>
554  <poco:formatted>San Francisco, CA</poco:formatted>
555 </poco:address>
556 <poco:urls>
557  <poco:type>homepage</poco:type>
558  <poco:value>http://example.com/blog.html</poco:value>
559  <poco:primary>true</poco:primary>
560
561 </poco:urls>
562 </activity:actor>
563  <link rel="alternate" type="text/html" href="http://example.net/mysite/notice/7"/>
564  <id>http://example.net/mysite/notice/7</id>
565  <published>2010-02-24T00:53:06+00:00</published>
566  <updated>2010-02-24T00:53:06+00:00</updated>
567  <link rel="ostatus:conversation" href="http://example.net/mysite/conversation/7"/>
568  <content type="html">Hey man, is that Freedom Code?! #&lt;span class=&quot;tag&quot;&gt;&lt;a href=&quot;http://example.net/mysite/tag/freedom&quot; rel=&quot;tag&quot;&gt;freedom&lt;/a&gt;&lt;/span&gt; #&lt;span class=&quot;tag&quot;&gt;&lt;a href=&quot;http://example.net/mysite/tag/hippy&quot; rel=&quot;tag&quot;&gt;hippy&lt;/a&gt;&lt;/span&gt;</content>
569  <georss:point>37.8313160 -122.2852473</georss:point>
570
571 </entry>
572 </feed>
573 EXAMPLE5;
574
575 $_example6 = <<<EXAMPLE6
576 <?xml version="1.0" encoding="UTF-8"?>
577 <rss version="2.0"
578         xmlns:content="http://purl.org/rss/1.0/modules/content/"
579         xmlns:wfw="http://wellformedweb.org/CommentAPI/"
580         xmlns:dc="http://purl.org/dc/elements/1.1/"
581         xmlns:atom="http://www.w3.org/2005/Atom"
582         xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
583         xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
584         xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
585         >
586
587         <channel>
588                 <title>WordPress.com News</title>
589                 <atom:link href="http://en.blog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
590                 <link>http://en.blog.wordpress.com</link>
591                 <description>The latest news on WordPress.com and the WordPress community.</description>
592                 <lastBuildDate>Thu, 18 Mar 2010 23:25:35 +0000</lastBuildDate>
593
594                 <generator>http://wordpress.com/</generator>
595                 <language>en</language>
596                 <sy:updatePeriod>hourly</sy:updatePeriod>
597                 <sy:updateFrequency>1</sy:updateFrequency>
598                 <cloud domain='en.blog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
599                 <image>
600                         <url>http://www.gravatar.com/blavatar/e6392390e3bcfadff3671c5a5653d95b?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
601                         <title>WordPress.com News</title>
602                         <link>http://en.blog.wordpress.com</link>
603                 </image>
604                 <atom:link rel="search" type="application/opensearchdescription+xml" href="http://en.blog.wordpress.com/osd.xml" title="WordPress.com News" />
605                 <atom:link rel='hub' href='http://en.blog.wordpress.com/?pushpress=hub'/>
606
607                 <item>
608                         <title>Rub-a-Dub-Dub in the PubSubHubbub</title>
609                         <link>http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/</link>
610                         <comments>http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/#comments</comments>
611                         <pubDate>Wed, 03 Mar 2010 16:48:12 +0000</pubDate>
612                         <dc:creator>Joseph Scott</dc:creator>
613
614                         <category><![CDATA[Feeds]]></category>
615                         <category><![CDATA[atom]]></category>
616                         <category><![CDATA[pubsubhubbub]]></category>
617                         <category><![CDATA[rss]]></category>
618
619                         <guid isPermaLink="false">http://en.blog.wordpress.com/?p=3857</guid>
620                         <description><![CDATA[From the tongue twisting name department we welcome PubSubHubbub, or as some people have shortened it to: PuSH.  Like rssCloud, PuSH is a way for services that subscribe to updates from your blog (think Google Reader, Bloglines or Netvibes) to get updates even faster.  In a nutshell, instead of having to periodically ask [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=en.blog.wordpress.com&blog=3584907&post=3857&subd=en.blog&ref=&feed=1" />]]></description>
621                                 <content:encoded><![CDATA[<p>From the tongue twisting name department we welcome <a href="http://code.google.com/p/pubsubhubbub/">PubSubHubbub</a>, or as some people have shortened it to: PuSH.  Like <a href="http://en.blog.wordpress.com/2009/09/07/rss-in-the-clouds/">rssCloud</a>, PuSH is a way for services that subscribe to updates from your blog (think Google Reader, Bloglines or Netvibes) to get updates even faster.  In a nutshell, instead of having to periodically ask your blog if there are any updates they can now register to automatically receive updates each time you publish new content.  In most cases these updates are sent out within a second or two of when you hit the publish button.</p>
622         <p>Today we&#8217;ve turned on PuSH support for the more than 10.5 million blogs on WordPress.com.  There&#8217;s nothing to configure, it&#8217;s working right now behind the scenes to help others keep up to date with your posts.</p>
623         <p>For those using the WordPress.org software we are releasing a new PuSH plugin: <a href="http://wordpress.org/extend/plugins/pushpress/">PuSHPress</a>.  This plugin differs from the current PuSH related plugins by including a built-in hub.</p>
624         <p>For more PuSH related reading check out the <a href="http://code.google.com/p/pubsubhubbub/">PubSubHubbub project site</a> and <a href="http://groups.google.com/group/pubsubhubbub?pli=1">Google Group</a>.  And if you really want to geek out there&#8217;s always the <a href="http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html">PubSubHubbub Spec</a> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
625         <br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/en.blog.wordpress.com/3857/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/en.blog.wordpress.com/3857/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/en.blog.wordpress.com/3857/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/en.blog.wordpress.com/3857/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/en.blog.wordpress.com/3857/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/en.blog.wordpress.com/3857/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/en.blog.wordpress.com/3857/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/en.blog.wordpress.com/3857/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/en.blog.wordpress.com/3857/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/en.blog.wordpress.com/3857/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=en.blog.wordpress.com&blog=3584907&post=3857&subd=en.blog&ref=&feed=1" />]]></content:encoded>
626                                 <wfw:commentRss>http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/feed/</wfw:commentRss>
627
628                         <slash:comments>96</slash:comments>
629
630                         <media:content url="http://1.gravatar.com/avatar/582b66ad5ae1b69c7601a990cb9a661a?s=96&#38;d=identicon" medium="image">
631                                 <media:title type="html">josephscott</media:title>
632                         </media:content>
633                 </item>
634         </channel>
635 </rss>
636 EXAMPLE6;
637
638 $_example7 = <<<EXAMPLE7
639 <?xml version="1.0" encoding="UTF-8"?>
640         <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:posterous="http://posterous.com/help/rss/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
641           <channel>
642             <title>evanpro's posterous</title>
643             <link>http://evanpro.posterous.com</link>
644             <description>Most recent posts at evanpro's posterous</description>
645             <generator>posterous.com</generator>
646             <link type="application/json" xmlns="http://www.w3.org/2005/Atom" rel="http://api.friendfeed.com/2008/03#sup" href="http://posterous.com/api/sup_update#56bcc5eb7"/>
647             <atom:link rel="self" href="http://evanpro.posterous.com/rss.xml"/>
648             <atom:link rel="hub" href="http://posterous.superfeedr.com"/>
649             <item>
650               <pubDate>Sat, 20 Mar 2010 07:32:31 -0700</pubDate>
651               <title>Checking out captain bones</title>
652               <link>http://evanpro.posterous.com/checking-out-captain-bones</link>
653               <guid>http://evanpro.posterous.com/checking-out-captain-bones</guid>
654               <description>
655                 <![CDATA[<p>
656                 <p>Bones!</p>
657
658         </p>
659
660         <p><a href="http://evanpro.posterous.com/checking-out-captain-bones">Permalink</a>
661
662                 | <a href="http://evanpro.posterous.com/checking-out-captain-bones#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>
663
664         </p>]]>
665               </description>
666               <posterous:author>
667                 <posterous:userImage>http://files.posterous.com/user_profile_pics/480326/2009-08-05-142447.jpg</posterous:userImage>
668                 <posterous:profileUrl>http://posterous.com/people/3sDslhaepotz</posterous:profileUrl>
669                 <posterous:firstName>Evan</posterous:firstName>
670                 <posterous:lastnNme>Prodromou</posterous:lastnNme>
671                 <posterous:nickName>evanpro</posterous:nickName>
672                 <posterous:displayName>Evan Prodromou</posterous:displayName>
673               </posterous:author>
674             </item>
675         </channel>
676 </rss>
677 EXAMPLE7;
678
679 $_example8 = <<<EXAMPLE8
680 <?xml version="1.0"?>
681 <feed xmlns="http://www.w3.org/2005/Atom">
682     <link href="http://pubsubhubbub.appspot.com/" rel="hub"/>
683     <title type="text">Activity Stream for: zcopley</title>
684     <id>http://cliqset.com/feed/atom?uid=zcopley</id>
685     <entry xmlns:service="http://activitystrea.ms/service-provider" xmlns:activity="http://activitystrea.ms/spec/1.0/">
686         <thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total>
687         <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
688         <published>2010-03-22T01:35:53.000Z</published>
689         <service:provider>
690             <name>flickr</name>
691             <uri>http://flickr.com</uri>
692             <icon>http://cliqset-services.s3.amazonaws.com/flickr.png</icon>
693         </service:provider>
694         <activity:object>
695             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
696             <title type="text">IMG_1368</title>
697             <link type="image/jpeg" rel="preview" href="http://media.cliqset.com/6f6fbee9d7dfbffc73b6ef626275eb5f_thumb.jpg"/>
698             <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/zcopley/4452933806/"/>
699         </activity:object>
700         <activity:object>
701             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
702             <title type="text">IMG_1365</title>
703             <link type="image/jpeg" rel="preview" href="http://media.cliqset.com/b8f3932cd0bba1b27f7c8b3ef986915e_thumb.jpg"/>
704             <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/zcopley/4442630390/"/>
705         </activity:object>
706         <activity:object xmlns:media="http://purl.org/syndication/atommedia">
707             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
708             <title type="text">Classic</title>
709             <link type="image/jpeg" rel="preview" href="http://media.cliqset.com/fc54c15f850b7a9a8efa644087a48c91_thumb.jpg"/>
710             <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/zcopley/4430754103/"/>
711             <media:description type="text">-Powered by pikchur.com/n0u</media:description>
712         </activity:object>
713         <activity:object>
714             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
715             <title type="text">IMG_1363</title>
716             <link type="image/jpeg" rel="preview" href="http://media.cliqset.com/4b1d307c9217e2114391a8b229d612cb_thumb.jpg"/>
717             <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/zcopley/4416969717/"/>
718         </activity:object>
719         <activity:object>
720             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
721             <title type="text">IMG_1361</title>
722             <link type="image/jpeg" rel="preview" href="http://media.cliqset.com/23d9b4b96b286e0347d36052f22f6e60_thumb.jpg"/>
723             <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/zcopley/4417734232/"/>
724         </activity:object>
725         <title type="text">zcopley posted some photos on Flickr</title>
726         <summary type="text">zcopley posted 5 photos on Flickr</summary>
727         <category scheme="http://schemas.cliqset.com/activity/categories/1.0" term="PhotoPosted" label="Photo Posted"/>
728         <updated>2010-03-22T20:46:42.778Z</updated>
729         <id>tag:cliqset.com,2010-03-22:/user/zcopley/SVgAZubGhtAnSAee</id>
730         <link href="http://cliqset.com/user/zcopley/SVgAZubGhtAnSAee" type="text/xhtml" rel="alternate" title="zcopley posted some photos on Flickr"/>
731         <author>
732             <name>zcopley</name>
733             <uri>http://cliqset.com/user/zcopley</uri>
734         </author>
735         <activity:actor xmlns:poco="http://portablecontacts.net/spec/1.0">
736             <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
737             <id>zcopley</id>
738             <poco:name>
739                 <poco:givenName>Zach</poco:givenName>
740                 <poco:familyName>Copley</poco:familyName>
741             </poco:name>
742             <link xmlns:media="http://purl.org/syndication/atommedia" type="image/png" rel="avatar" href="http://dynamic.cliqset.com/avatar/zcopley?s=80" media:height="80" media:width="80"/>
743             <link xmlns:media="http://purl.org/syndication/atommedia" type="image/png" rel="avatar" href="http://dynamic.cliqset.com/avatar/zcopley?s=120" media:height="120" media:width="120"/>
744             <link xmlns:media="http://purl.org/syndication/atommedia" type="image/png" rel="avatar" href="http://dynamic.cliqset.com/avatar/zcopley?s=200" media:height="200" media:width="200"/>
745         </activity:actor>
746     </entry>
747 </feed>
748 EXAMPLE8;
749
750 $_example9 = <<<EXAMPLE9
751 <?xml version="1.0" encoding="utf-8"?>
752 <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:media="http://search.yahoo.com/mrss" xmlns:activity="http://activitystrea.ms/spec/1.0/">
753     <link rel="self" type="application/atom+xml" href="http://buzz.googleapis.com/feeds/117848251937215158042/public/posted"/>
754     <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
755     <title type="text">Google Buzz</title>
756     <updated>2010-03-22T01:55:53.596Z</updated>
757     <id>tag:google.com,2009:buzz-feed/public/posted/117848251937215158042</id>
758     <generator>Google - Google Buzz</generator>
759     <entry>
760         <title type="html">Buzz by Zach Copley from Flickr</title>
761         <summary type="text">IMG_1366</summary>
762         <published>2010-03-18T04:29:23.000Z</published>
763         <updated>2010-03-18T05:14:03.325Z</updated>
764         <id>tag:google.com,2009:buzz/z12zwdhxowq2d13q204cjr04kzu0cns5gh0</id>
765         <link rel="alternate" type="text/html" href="http://www.google.com/buzz/117848251937215158042/ZU7b6mHJEmC/IMG-1366"/>
766         <author>
767             <name>Zach Copley</name>
768             <uri>http://www.google.com/profiles/zcopley</uri>
769         </author>
770         <content type="html">&lt;div&gt;IMG_1366&lt;/div&gt;</content>
771         <link rel="enclosure" href="http://www.flickr.com/photos/22823034@N00/4442630700" type="image/jpeg" title="IMG_1366"/>
772         <media:content url="http://www.flickr.com/photos/22823034@N00/4442630700" type="image/jpeg" medium="image">
773             <media:title>IMG_1366</media:title>
774             <media:player url="http://farm5.static.flickr.com/4053/4442630700_980b19a1a6_o.jpg" height="1600" width="1200"/>
775         </media:content>
776         <link rel="enclosure" href="http://www.flickr.com/photos/22823034@N00/4442630390" type="image/jpeg" title="IMG_1365"/>
777         <media:content url="http://www.flickr.com/photos/22823034@N00/4442630390" type="image/jpeg" medium="image">
778             <media:title>IMG_1365</media:title>
779             <media:player url="http://farm5.static.flickr.com/4043/4442630390_62da5560ae_o.jpg" height="1200" width="1600"/>
780         </media:content>
781         <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
782         <activity:object>
783             <activity:object-type>http://activitystrea.ms/schema/1.0/photo</activity:object-type>
784             <id>tag:google.com,2009:buzz/z12zwdhxowq2d13q204cjr04kzu0cns5gh0</id>
785             <title>Buzz by Zach Copley from Flickr</title>
786             <content type="html">&lt;div&gt;IMG_1366&lt;/div&gt;</content>
787             <link rel="enclosure" href="http://www.flickr.com/photos/22823034@N00/4442630700" type="image/jpeg" title="IMG_1366"/>
788             <link rel="enclosure" href="http://www.flickr.com/photos/22823034@N00/4442630390" type="image/jpeg" title="IMG_1365"/>
789         </activity:object>
790         <link rel="replies" type="application/atom+xml" href="http://buzz.googleapis.com/feeds/117848251937215158042/comments/z12zwdhxowq2d13q204cjr04kzu0cns5gh0" thr:count="0"/>
791         <thr:total>0</thr:total>
792     </entry>
793 </feed>
794 EXAMPLE9;