public static function get_bitlove_feed_url($feed_id) { $feed = \Podlove\Model\Feed::find_one_by_id($feed_id); $cache_key = "podlove_bitlove_feed_url_" . $feed_id; if (($bitlove_feed_url = get_transient($cache_key)) !== FALSE) { return $bitlove_feed_url; } else { $subscribe_url = $feed->get_subscribe_url(); $url = 'http://api.bitlove.org/feed-lookup.json?url=' . $subscribe_url; $curl = new \Podlove\Http\Curl(); $curl->request($url, array('headers' => array('Content-type' => 'application/json'))); $response = $curl->get_response(); if (!$curl->isSuccessful()) { return array(); } $decoded_answer = get_object_vars(json_decode($response['body'])); $bitlove_url = $decoded_answer[$subscribe_url][0]; // The response is always the first array element set_transient($cache_key, $bitlove_url, 60 * 60 * 24); return $bitlove_url; } }