Esempio n. 1
0
 /**
  * Send a cURL Wordpress request to retrieve the requested data from the Vimeo API.
  *
  * @param  string $endpoint Vimeo API endpoint
  * @return array  Response Body
  */
 private function _make_vimeo_request($endpoint, $params, $last_modified)
 {
     try {
         $response = $this->_vimeo->request($endpoint, $params, 'GET', $last_modified);
         switch ($response['status']) {
             case 200:
                 return $response['body'];
             case 304:
                 return NULL;
             case 400:
                 throw new Vimeography_Exception(__('a bad request made was made. ', 'vimeography') . $response['body']->error);
             case 401:
                 throw new Vimeography_Exception(__('an invalid token was used for the API request. Try removing your Vimeo token on the Vimeography Pro page and following the steps again to create a Vimeo app.', 'vimeography'));
             case 404:
                 throw new Vimeography_Exception(__('the plugin could not retrieve data from the Vimeo API! ', 'vimeography') . $response['body']->error);
             case 500:
                 throw new Vimeography_Exception(__('looks like Vimeo is having some API issues. Try reloading, or, check back in a few minutes.', 'vimeography'));
             default:
                 throw new Vimeography_Exception(sprintf(__('Unknown response status %1$d, %2$s', 'vimeography'), $response['status'], $response['body']->error));
         }
     } catch (Exception $e) {
         throw new Vimeography_Exception(__('the request to Vimeo failed. ', 'vimeography') . $e->getMessage());
     }
 }