summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormillette <millette@controlyourself.ca>2008-11-28 20:24:46 -0500
committermillette <millette@controlyourself.ca>2008-11-28 20:24:46 -0500
commit70c90b50b01cc9669065acb3b609b464e1227de0 (patch)
tree94d780ab6bfd0916f52909e8493bf3c58ed48472 /lib
parent5878647c55a5f1c6fab5b27c627dde091067ce88 (diff)
fix shorturl_api so it works even when 3rd party is down.
darcs-hash:20081129012446-099f7-e2d0398dc22fc3e83398920f46da6cf1691544b3.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/Shorturl_api.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php
index 5af407fc5..7beae0ec6 100644
--- a/lib/Shorturl_api.php
+++ b/lib/Shorturl_api.php
@@ -76,7 +76,9 @@ class LilUrl extends ShortUrlApi {
$data['longurl'] = $url;
$response = $this->http_post($data);
if (!$response) return $url;
- $x = simplexml_load_string($response)->body->p[0]->a->attributes();
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $x = $y->body->p[0]->a->attributes();
if (isset($x['href'])) return $x['href'];
return $url;
}
@@ -92,7 +94,9 @@ class PtitUrl extends ShortUrlApi {
$response = $this->http_get($url);
if (!$response) return $url;
$response = $this->tidy($response);
- $xml = simplexml_load_string($response)->body->center->table->tr->td->pre->a->attributes();
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->center->table->tr->td->pre->a->attributes();
if (isset($xml['href'])) return $xml['href'];
return $url;
}
@@ -107,10 +111,11 @@ class TightUrl extends ShortUrlApi {
$response = $this->http_get($url);
if (!$response) return $url;
$response = $this->tidy($response);
- $xml = simplexml_load_string($response)->body->p[0]->code[0]->a->attributes();
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->p[0]->code[0]->a->attributes();
if (isset($xml['href'])) return $xml['href'];
return $url;
}
}
-