- 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;
- } else if (isset($data['statusCode']) && $data['statusCode'] == 'ERROR') {
- $code = $data['errorCode'];
- $msg = $data['errorMessage'];
+ if ($json['status_code'] == 200) {
+ if (isset($json['data']['url'])) {
+ common_log(LOG_INFO, "bit.ly returned ".$json['data']['url']." as short URL for $url");
+ return $json['data']['url'];