X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FBitlyUrl%2FBitlyUrlPlugin.php;h=532e66fbc73d2ec7bb06ddce6d6d3e2e672d053d;hb=e211e6228d7f7742967686005c693697e327e366;hp=93a35b3f384d85b52e2ed784560e37eed34a5b85;hpb=06c4212bd4db8815b3f91e5eab3a079784738ae3;p=quix0rs-gnu-social.git diff --git a/plugins/BitlyUrl/BitlyUrlPlugin.php b/plugins/BitlyUrl/BitlyUrlPlugin.php index 93a35b3f38..532e66fbc7 100644 --- a/plugins/BitlyUrl/BitlyUrlPlugin.php +++ b/plugins/BitlyUrl/BitlyUrlPlugin.php @@ -33,8 +33,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php'; - class BitlyUrlPlugin extends UrlShortenerPlugin { public $shortenerName = 'bit.ly'; @@ -118,7 +116,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin $params = http_build_query(array( 'login' => $this->getLogin(), 'apiKey' => $this->getApiKey()), '', '&'); - $serviceUrl = sprintf($this->serviceUrl, $url) . '&' . $params; + $serviceUrl = sprintf($this->serviceUrl, urlencode($url)) . '&' . $params; $request = HTTPClient::start(); return $request->get($serviceUrl); @@ -145,6 +143,10 @@ class BitlyUrlPlugin extends UrlShortenerPlugin common_log(LOG_INFO, $body); $json = json_decode($body, true); if ($json['statusCode'] == 'OK') { + if (!isset($json['results'][$url])) { + common_log(LOG_ERR, "bit.ly returned OK response, but didn't find expected URL $url in $body"); + return false; + } $data = $json['results'][$url]; if (isset($data['shortUrl'])) { return true;