git.cweiske.de
/
shpub.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
971586c
)
Load HTML as HTML, resolve relative endpoint URLs
author
Christian Weiske
<cweiske@cweiske.de>
Wed, 7 Sep 2016 05:35:41 +0000
(07:35 +0200)
committer
Christian Weiske
<cweiske@cweiske.de>
Wed, 7 Sep 2016 05:35:41 +0000
(07:35 +0200)
src/shpub/Config/Endpoints.php
patch
|
blob
|
history
diff --git
a/src/shpub/Config/Endpoints.php
b/src/shpub/Config/Endpoints.php
index 62e7c4905ecd2698c572cc0bac605635747af726..2e58e7abd15699c4389ee267bdb7b517add21d60 100644
(file)
--- a/
src/shpub/Config/Endpoints.php
+++ b/
src/shpub/Config/Endpoints.php
@@
-41,39
+41,49
@@
class Config_Endpoints
public function discover($server)
{
//TODO: discovery via link headers
public function discover($server)
{
//TODO: discovery via link headers
- $sx = simplexml_load_file($server);
+ $baseUrl = new \Net_URL2($server);
+
+ $doc = new \DOMDocument();
+ $doc->loadHTMLFile($server);
+ $sx = simplexml_import_dom($doc);
if ($sx === false) {
Log::err('Error loading URL: ' . $server);
exit(1);
}
if ($sx === false) {
Log::err('Error loading URL: ' . $server);
exit(1);
}
- $sx->registerXPathNamespace('h', 'http://www.w3.org/1999/xhtml');
+
//
$sx->registerXPathNamespace('h', 'http://www.w3.org/1999/xhtml');
$auths = $sx->xpath(
$auths = $sx->xpath(
- '/h
:html/h:head/h:
link[@rel="authorization_endpoint" and @href]'
+ '/h
tml/head/
link[@rel="authorization_endpoint" and @href]'
);
if (!count($auths)) {
);
if (!count($auths)) {
- Log::err('No authorization endpoint found
'
);
+ Log::err('No authorization endpoint found
at ' . $server
);
exit(1);
}
exit(1);
}
- $this->authorization = (string) $auths[0]['href'];
+ $this->authorization = (string) $baseUrl->resolve(
+ (string) $auths[0]['href']
+ );
$tokens = $sx->xpath(
$tokens = $sx->xpath(
- '/h
:html/h:head/h:
link[@rel="token_endpoint" and @href]'
+ '/h
tml/head/
link[@rel="token_endpoint" and @href]'
);
if (!count($tokens)) {
Log::err('No token endpoint found');
exit(1);
}
);
if (!count($tokens)) {
Log::err('No token endpoint found');
exit(1);
}
- $this->token = (string) $tokens[0]['href'];
+ $this->token = (string) $baseUrl->resolve(
+ (string) $tokens[0]['href']
+ );
$mps = $sx->xpath(
$mps = $sx->xpath(
- '/h
:html/h:head/h:
link[@rel="micropub" and @href]'
+ '/h
tml/head/
link[@rel="micropub" and @href]'
);
if (!count($mps)) {
Log::err('No micropub endpoint found');
exit(1);
}
);
if (!count($mps)) {
Log::err('No micropub endpoint found');
exit(1);
}
- $this->micropub = (string) $mps[0]['href'];
+ $this->micropub = (string) $baseUrl->resolve(
+ (string) $mps[0]['href']
+ );
}
public function load($server)
}
public function load($server)