BitlyPlugin: fix for shortening URLs containing ampersand (&)
This commit is contained in:
parent
af31767b63
commit
bcccbd6d8a
@ -118,7 +118,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin
|
|||||||
$params = http_build_query(array(
|
$params = http_build_query(array(
|
||||||
'login' => $this->getLogin(),
|
'login' => $this->getLogin(),
|
||||||
'apiKey' => $this->getApiKey()), '', '&');
|
'apiKey' => $this->getApiKey()), '', '&');
|
||||||
$serviceUrl = sprintf($this->serviceUrl, $url) . '&' . $params;
|
$serviceUrl = sprintf($this->serviceUrl, urlencode($url)) . '&' . $params;
|
||||||
|
|
||||||
$request = HTTPClient::start();
|
$request = HTTPClient::start();
|
||||||
return $request->get($serviceUrl);
|
return $request->get($serviceUrl);
|
||||||
@ -145,6 +145,10 @@ class BitlyUrlPlugin extends UrlShortenerPlugin
|
|||||||
common_log(LOG_INFO, $body);
|
common_log(LOG_INFO, $body);
|
||||||
$json = json_decode($body, true);
|
$json = json_decode($body, true);
|
||||||
if ($json['statusCode'] == 'OK') {
|
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];
|
$data = $json['results'][$url];
|
||||||
if (isset($data['shortUrl'])) {
|
if (isset($data['shortUrl'])) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user