$links = $this->getLinks($me);
+ if ($links === false) {
+ return $this->errorOut('Error fetching URL: ' . $me);
+ }
if (!count($links)) {
return $this->errorOut('No links found');
}
//step 1: micropub discovery
$links = $this->getLinks($url);
+ if ($links === false) {
+ return $this->errorOut('Error fetching URL: ' . $url);
+ }
if (!count($links)) {
return $this->errorOut('No links found');
}
}
$links = $this->getLinks($_GET['me']);
+ if ($links === false) {
+ return $this->errorOut('Error fetching URL: ' . $_GET['me']);
+ }
if (!isset($links['token_endpoint'])) {
return $this->errorOut('No token endpoint found');
}
/**
* Extract link relations from a given URL
+ *
+ * @param string $url URL to extract links from
+ *
+ * @return bool|array Array of links, or false on HTTP error
*/
protected function getLinks($url)
{
'url' => $url,
]
);
+ if ($html === false) {
+ return false;
+ }
+
//Loading invalid HTML is tedious.
// quick hack with regex. yay!
preg_match_all('#<link[^>]+?>#', $html, $matches);