7 * @param string $url collection feed URL
8 * @param string $user auth username
9 * @param string $pass auth password
11 function __construct($url, $user, $pass)
19 * @param string $baseUrl to attempt feed discovery from
20 * @return AtomPubClient
22 static function discoverFromPage($baseUrl)
32 function post($stuff, $type='application/atom+xml;type=entry')
35 // optional 'Slug' header too
37 if ($response->getStatus() == '201') {
39 // MUST have a "Location" header
40 // if it has a Content-Location header, it MUST match Location
41 // and if it does, check the response body -- it should match what we posted, more or less.
43 throw new Exception("Expected HTTP 201 on POST, got " . $response->getStatus());
47 function put($data, $type='application/atom+xml;type=entry')
50 // must get a 200 back.
51 // unlike post, we don't get the location too.
55 // discover the feed...
57 // confirm the feed has edit links ..... ?
59 $pub = new AtomPubClient($url, $user, $pass);
62 $target = $pub->post($atom);
64 // make sure it's accessible
65 // fetch $target -- should give us the atom entry
66 // edit URL should match
68 // refetch the feed; make sure the new entry is in there
69 // edit URL should match
71 // try editing! it should fail.
73 $target2 = $pub->put($target, $atom2);
74 // FAIL! this shouldn't work.
75 } catch (AtomPubPermissionDeniedException $e) {
82 // fetch $target -- it should be gone now
84 // fetch the feed again; the new entry should be gone again
92 // make sure the posts go through or not depending on the subs
93 // remove subscriptions
94 // test that they don't go through now
96 // group memberships too
101 // make sure we can't post to someone else's feed!
102 // make sure we can't delete someone else's messages
103 // make sure we can't create/delete someone else's subscriptions
104 // make sure we can't create/delete someone else's group memberships