/**
* Run this request and return the data.
*
+ * @throws Horde_Service_Facebook_Exception
+ *
* @param string $dataFormat Optionally specify the datatype to return.
*
* @return Either raw XML, JSON, or an array of decoded values.
return $result;
}
+ /**
+ * @throws Horde_Service_Facebook_Exception
+ * @param $method
+ * @param $params
+ * @return unknown_type
+ */
protected function _postRequest($method, &$params)
{
$this->_finalizeParams($method, $params);
// we have to manually create the post string or we get an
// invalid signature error from FB
$post_string = $this->_createPostString($params);
- $result = $this->_http->post(Horde_Service_Facebook::REST_SERVER_ADDR, $post_string);
+ try {
+ $result = $this->_http->post(Horde_Service_Facebook::REST_SERVER_ADDR, $post_string);
+ } catch (Exception $e) {
+ // Not much we can do about a client exception - rethrow it as
+ // temporarily unavailable.
+ throw new Horde_Service_Facebook_Exception(_("Service is unavailable. Please try again later."));
+ }
return $result->getBody();
}
}
/**
- * TODO
+ * Execute a RFC1867/RFC1341 Multipart Http Transaction.
*
- * @param $method
- * @param $params
- * @param $file
- * @param $server_addr
- * @return unknown_type
+ * @throws Horde_Service_Facebook_Exception
+ *
+ * @return string
*/
private function _multipartHttpTransaction()
{
$content_lines[] = $close_delimiter;
$content_lines[] = '';
$content = implode("\r\n", $content_lines);
- $result = $this->_http->request('POST',
- Horde_Service_Facebook::REST_SERVER_ADDR,
- $content,
- array('Content-Type' => $content_type,
- 'Content-Length' => strlen($content)));
+ try {
+ $result = $this->_http->request('POST',
+ Horde_Service_Facebook::REST_SERVER_ADDR,
+ $content,
+ array('Content-Type' => $content_type,
+ 'Content-Length' => strlen($content)));
+ } catch (Exception $e) {
+ throw new Horde_Service_Facebook_Exception(sprintf(_("Upload failed: %s"), $e->getMessage()));
+ }
+
return $result->getBody();
}