function flickr_api_call($method, $args = array())
{
    $args['api_key'] = $GLOBALS['cfg']['flickr_apikey'];
    $args['method'] = $method;
    $args['format'] = 'json';
    $args['nojsoncallback'] = 1;
    if (isset($args['auth_token'])) {
        $api_sig = _flickr_api_sign_args($args);
        $args['api_sig'] = $api_sig;
    }
    $url = "http://api.flickr.com/services/rest";
    $url = $url . "?" . http_build_query($args);
    #dumper($url);
    # The Flickr API is being slow (20110429/straup)
    $headers = array();
    $more = array('http_timeout' => 5);
    $rsp = http_get($url, $headers, $more);
    # At some point we may need to do POSTs but for
    # now it's not really an issue
    # $rsp = http_post($url, $args);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $json = json_decode($rsp['body'], 'as a hash');
    if (!$json) {
        return array('ok' => 0, 'error' => 'failed to parse response');
    }
    if ($json['stat'] != 'ok') {
        return array('ok' => 0, 'error' => $json['message']);
    }
    unset($json['stat']);
    return array('ok' => 1, 'rsp' => $json);
}
function flickr_api_call_build($method, $args = array(), $more = array())
{
    $args['api_key'] = $GLOBALS['cfg']['flickr_api_key'];
    $args['method'] = $method;
    $args['format'] = 'json';
    $args['nojsoncallback'] = 1;
    if (isset($args['auth_token']) || isset($more['sign'])) {
        $api_sig = _flickr_api_sign_args($args);
        $args['api_sig'] = $api_sig;
    }
    $url = $GLOBALS['cfg']['flickr_api_endpoint'];
    return array($url, $args);
}