function call($method, $args = array()) { $args = array_merge(array('method' => $method, 'api_key' => $this->key), $args); ksort($args); $args = array_merge($args, array('api_sig' => $this->sign($args))); ksort($args); $call = new RemoteRequest($this->endpoint, 'POST'); $args['api_key'] = $this->key; if ($method == 'upload') { $call = new RemoteRequest($this->uploadendpoint, 'POST'); if (is_file($args['photo'])) { // we have a valid file and filename $call->set_file('photo', $args['photo']); unset($args['photo']); } } $call->set_timeout($this->conntimeout); $call->set_postdata($args); try { $result = $call->execute(); } catch (RemoteRequest_Timeout $t) { Session::error('Currently unable to connect to Flickr.', 'flickr API'); return false; } catch (Exception $e) { // at the moment we're using the same error message, though this is more catastrophic Session::error('Currently unable to connect to Flickr.', 'flickr API'); return false; } $response = $call->get_response_body(); try { $xml = new SimpleXMLElement($response); return $xml; } catch (Exception $e) { Session::error('Unable to process Flickr response.', 'flickr API'); return false; } }