git.cweiske.de
/
anoweco.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
send linkback when a post is created
[anoweco.git]
/
www
/
micropub.php
diff --git
a/www/micropub.php
b/www/micropub.php
index 375920b4fa400f7ecbcf297fb4a255c0fc900767..e028782695fa5ea686b464fa2f125763eb620984 100644
(file)
--- a/
www/micropub.php
+++ b/
www/micropub.php
@@
-82,37
+82,47
@@
function handleCreate($json, $token)
);
}
);
}
- if (!isset($json->properties->{'in-reply-to'})) {
- mpError(
- 'HTTP/1.0 400 Bad Request',
- 'invalid_request',
- 'Only replies accepted'
- );
- }
-
$storage = new Storage();
$storage = new Storage();
+ $lb = new Linkback();
try {
$id = $storage->addComment($json, $userId);
try {
$id = $storage->addComment($json, $userId);
+ $lb->ping($id);
header('HTTP/1.0 201 Created');
header('Location: ' . Urls::full(Urls::comment($id)));
exit();
} catch (\Exception $e) {
header('HTTP/1.0 201 Created');
header('Location: ' . Urls::full(Urls::comment($id)));
exit();
} catch (\Exception $e) {
- //FIXME: return correct status code
- header('HTTP/1.0 500 Internal Server Error');
+ if ($e->getCode() == 400) {
+ mpError(
+ 'HTTP/1.0 400 Bad Request',
+ 'invalid_request',
+ $e->getMessage()
+ );
+ }
+
+ mpError(
+ 'HTTP/1.0 500 Internal Server Error',
+ 'this_violates_the_spec',
+ $e->getMessage()
+ );
exit();
}
}
function getTokenFromHeader()
{
exit();
}
}
function getTokenFromHeader()
{
- if (!isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $auth = $_SERVER['HTTP_AUTHORIZATION'];
+ } else if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
+ //php-cgi has it there
+ $auth = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
+ } else {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
'Authorization HTTP header missing'
);
}
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
'Authorization HTTP header missing'
);
}
- list($bearer, $token) = explode(' ', $
_SERVER['HTTP_AUTHORIZATION']
, 2);
+ list($bearer, $token) = explode(' ', $
auth
, 2);
if ($bearer !== 'Bearer') {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
if ($bearer !== 'Bearer') {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',